-
-
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(delegate): entity create fails when inheriting from a delegate mo…
…del that extends an abstract model
- Loading branch information
Showing
4 changed files
with
65 additions
and
6 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
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
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
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,41 @@ | ||
import { loadSchema } from '@zenstackhq/testtools'; | ||
describe('issue 1560', () => { | ||
it('regression', async () => { | ||
const { enhance } = await loadSchema( | ||
` | ||
model User { | ||
id String @id @default(cuid()) | ||
name String | ||
ownedItems OwnedItem[] | ||
} | ||
abstract model Base { | ||
id String @id @default(cuid()) | ||
ownerId String | ||
owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade) | ||
} | ||
model OwnedItem extends Base { | ||
ownedItemType String | ||
@@delegate(ownedItemType) | ||
} | ||
model List extends OwnedItem { | ||
title String | ||
} | ||
`, | ||
{ enhancements: ['delegate'] } | ||
); | ||
|
||
const db = enhance(); | ||
await db.user.create({ data: { id: '1', name: 'user1' } }); | ||
await expect( | ||
db.list.create({ data: { id: '1', title: 'list1', owner: { connect: { id: '1' } } } }) | ||
).resolves.toMatchObject({ | ||
id: '1', | ||
title: 'list1', | ||
ownerId: '1', | ||
ownedItemType: 'List', | ||
}); | ||
}); | ||
}); |