-
-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: foreign key constraint ambiguity in generated delegate prisma sc…
…hema (#1060)
- Loading branch information
Showing
2 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
tests/integration/tests/enhancements/with-delegate/regressions.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { loadSchema } from '@zenstackhq/testtools'; | ||
|
||
describe('Regression tests', () => { | ||
it('FK Constraint Ambiguity', async () => { | ||
const schema = ` | ||
model User { | ||
id String @id @default(cuid()) | ||
name String | ||
userRankings UserRanking[] | ||
userFavorites UserFavorite[] | ||
} | ||
model Entity { | ||
id String @id @default(cuid()) | ||
name String | ||
type String | ||
userRankings UserRanking[] | ||
userFavorites UserFavorite[] | ||
@@delegate(type) | ||
} | ||
model Person extends Entity { | ||
} | ||
model Studio extends Entity { | ||
} | ||
model UserRanking { | ||
id String @id @default(cuid()) | ||
rank Int | ||
entityId String | ||
entity Entity @relation(fields: [entityId], references: [id], onUpdate: NoAction) | ||
userId String | ||
user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: NoAction) | ||
} | ||
model UserFavorite { | ||
id String @id @default(cuid()) | ||
entityId String | ||
entity Entity @relation(fields: [entityId], references: [id], onUpdate: NoAction) | ||
userId String | ||
user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: NoAction) | ||
} | ||
`; | ||
|
||
await loadSchema(schema, { pushDb: false, provider: 'postgresql' }); | ||
}); | ||
}); |