Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delegating models can't use @@map() #1167

Closed
keanugrieves opened this issue Mar 20, 2024 · 3 comments
Closed

Delegating models can't use @@map() #1167

keanugrieves opened this issue Mar 20, 2024 · 3 comments

Comments

@keanugrieves
Copy link

keanugrieves commented Mar 20, 2024

Description and expected behavior
Doing this throws an error when running zenstack generate:

model FileAsset {
  delegate_type String
  ...
  @@delegate(delegate_type)
  @@map("file_assets")
}

model ImageAsset extends FileAsset {
  ...
  @@map("image_assets")
}

...after generating the following in schema.prisma:

/// @@delegate(delegate_type)
model FileAsset {
    ...
    delegate_aux_imageAsset ImageAsset?

    @@map("file_assets")
}

model ImageAsset {
    ...
    delegate_aux_fileAsset FileAsset @relation(fields: [id], references: [id], onDelete: Cascade, onUpdate: Cascade)

    @@map("file_assets")
    @@map("image_assets")
}

Screenshots
Screenshot 2024-03-20 at 1 25 28 PM

Environment (please complete the following information):

  • ZenStack version: 2.0.0-beta.1
  • Prisma version: 5.11.0
  • Database type: postgresql
@keanugrieves keanugrieves changed the title Delegates can't respect @@map() attribute Delegates can't use @@map() Mar 20, 2024
@keanugrieves keanugrieves changed the title Delegates can't use @@map() Delegating models can't use @@map() Mar 20, 2024
@ymc9
Copy link
Member

ymc9 commented Mar 21, 2024

Great to see you here again @keanugrieves 😄. Good catch! The @@map attribute should be inherited.

@ymc9 ymc9 added this to the v2.0.0 milestone Mar 21, 2024
@keanugrieves
Copy link
Author

keanugrieves commented Mar 21, 2024

Great to see you here again @keanugrieves 😄. Good catch! The @@map attribute should be inherited.

I never left! 😄

Unless I'm misunderstanding something, the ideal behavior is that @@map should not be inherited, right? It's not a big deal except I'm using ZenStack in an organization that follows the plural snake naming conventions for tables.

@ymc9
Copy link
Member

ymc9 commented Mar 24, 2024

Great to see you here again @keanugrieves 😄. Good catch! The @@map attribute should be inherited.

I never left! 😄

Unless I'm misunderstanding something, the ideal behavior is that @@map should not be inherited, right? It's not a big deal except I'm using ZenStack in an organization that follows the plural snake naming conventions for tables.

Yes, sorry that I missed typing "not" in my original reply ... Will fix it soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants