zenstackhq / zenstack

Fullstack TypeScript toolkit that enhances Prisma ORM with flexible Authorization layer for RBAC/ABAC/PBAC/ReBAC, offering auto-generated type-safe APIs and frontend hooks.
https://zenstack.dev
MIT License
2.07k stars 88 forks source link

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

Closed keanugrieves closed 6 months ago

keanugrieves commented 6 months ago

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):

ymc9 commented 6 months ago

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

keanugrieves commented 6 months ago

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 commented 6 months ago

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.