-
-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: issues with cross-model comparison identification and injection (#…
- Loading branch information
Showing
19 changed files
with
118 additions
and
95 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ plugins { | |
} | ||
|
||
group = "dev.zenstack" | ||
version = "2.2.1" | ||
version = "2.2.2" | ||
|
||
repositories { | ||
mavenCentral() | ||
|
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
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
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
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,57 @@ | ||
import { loadSchema } from '@zenstackhq/testtools'; | ||
describe('issue 1506', () => { | ||
it('regression', async () => { | ||
const { prisma, enhance } = await loadSchema( | ||
` | ||
model A { | ||
id Int @id @default(autoincrement()) | ||
value Int | ||
b B @relation(fields: [bId], references: [id]) | ||
bId Int @unique | ||
@@allow('read', true) | ||
} | ||
model B { | ||
id Int @id @default(autoincrement()) | ||
value Int | ||
a A? | ||
c C @relation(fields: [cId], references: [id]) | ||
cId Int @unique | ||
@@allow('read', value > c.value) | ||
} | ||
model C { | ||
id Int @id @default(autoincrement()) | ||
value Int | ||
b B? | ||
@@allow('read', true) | ||
} | ||
`, | ||
{ preserveTsFiles: true, logPrismaQuery: true } | ||
); | ||
|
||
await prisma.a.create({ | ||
data: { | ||
value: 3, | ||
b: { | ||
create: { | ||
value: 2, | ||
c: { | ||
create: { | ||
value: 1, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
const db = enhance(); | ||
const read = await db.a.findMany({ include: { b: true } }); | ||
expect(read).toHaveLength(1); | ||
expect(read[0].b).toBeTruthy(); | ||
}); | ||
}); |
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,27 @@ | ||
import { loadSchema } from '@zenstackhq/testtools'; | ||
describe('issue 1507', () => { | ||
it('regression', async () => { | ||
const { prisma, enhance } = await loadSchema( | ||
` | ||
model User { | ||
id Int @id @default(autoincrement()) | ||
age Int | ||
} | ||
model Profile { | ||
id Int @id @default(autoincrement()) | ||
age Int | ||
@@allow('read', auth().age == age) | ||
} | ||
`, | ||
{ preserveTsFiles: true, logPrismaQuery: true } | ||
); | ||
|
||
await prisma.profile.create({ data: { age: 18 } }); | ||
await prisma.profile.create({ data: { age: 20 } }); | ||
const db = enhance({ id: 1, age: 18 }); | ||
await expect(db.profile.findMany()).resolves.toHaveLength(1); | ||
await expect(db.profile.count()).resolves.toBe(1); | ||
}); | ||
}); |