Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ymc9 authored Aug 14, 2023
1 parent f6b68da commit 2ef93cb
Show file tree
Hide file tree
Showing 14 changed files with 111 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zenstack-monorepo",
"version": "1.0.0-beta.17",
"version": "1.0.0-beta.18",
"description": "",
"scripts": {
"build": "pnpm -r build",
Expand Down
2 changes: 1 addition & 1 deletion packages/language/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenstackhq/language",
"version": "1.0.0-beta.17",
"version": "1.0.0-beta.18",
"displayName": "ZenStack modeling language compiler",
"description": "ZenStack modeling language compiler",
"homepage": "https://zenstack.dev",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/openapi/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zenstackhq/openapi",
"displayName": "ZenStack Plugin and Runtime for OpenAPI",
"version": "1.0.0-beta.17",
"version": "1.0.0-beta.18",
"description": "ZenStack plugin and runtime supporting OpenAPI",
"main": "index.js",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/swr/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zenstackhq/swr",
"displayName": "ZenStack plugin for generating SWR hooks",
"version": "1.0.0-beta.17",
"version": "1.0.0-beta.18",
"description": "ZenStack plugin for generating SWR hooks",
"main": "index.js",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/tanstack-query/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zenstackhq/tanstack-query",
"displayName": "ZenStack plugin for generating tanstack-query hooks",
"version": "1.0.0-beta.17",
"version": "1.0.0-beta.18",
"description": "ZenStack plugin for generating tanstack-query hooks",
"main": "index.js",
"exports": {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/trpc/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zenstackhq/trpc",
"displayName": "ZenStack plugin for tRPC",
"version": "1.0.0-beta.17",
"version": "1.0.0-beta.18",
"description": "ZenStack plugin for tRPC",
"main": "index.js",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zenstackhq/runtime",
"displayName": "ZenStack Runtime Library",
"version": "1.0.0-beta.17",
"version": "1.0.0-beta.18",
"description": "Runtime of ZenStack for both client-side and server-side environments.",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/schema/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"publisher": "zenstack",
"displayName": "ZenStack Language Tools",
"description": "A toolkit for building secure CRUD apps with Next.js + Typescript",
"version": "1.0.0-beta.17",
"version": "1.0.0-beta.18",
"author": {
"name": "ZenStack Team"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
getPrismaClientImportSpec,
hasAttribute,
hasValidationAttributes,
isForeignKeyField,
PluginError,
PluginOptions,
resolved,
Expand Down Expand Up @@ -274,6 +275,7 @@ export default class PolicyGenerator {
// we can't check based on create input
return false;
}

if (
isDataModelField(expr.target.ref) &&
expr.target.ref.$container === model &&
Expand All @@ -284,6 +286,12 @@ export default class PolicyGenerator {
// based on create input
return false;
}

if (isDataModelField(expr.target.ref) && isForeignKeyField(expr.target.ref)) {
// reference to foreign key field
// we can't check based on create input
return false;
}
}

return true;
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenstackhq/sdk",
"version": "1.0.0-beta.17",
"version": "1.0.0-beta.18",
"description": "ZenStack plugin development SDK",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenstackhq/server",
"version": "1.0.0-beta.17",
"version": "1.0.0-beta.18",
"displayName": "ZenStack Server-side Adapters",
"description": "ZenStack server-side adapters",
"homepage": "https://zenstack.dev",
Expand Down
2 changes: 1 addition & 1 deletion packages/testtools/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenstackhq/testtools",
"version": "1.0.0-beta.17",
"version": "1.0.0-beta.18",
"description": "ZenStack Test Tools",
"main": "index.js",
"publishConfig": {
Expand Down
45 changes: 41 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 51 additions & 0 deletions tests/integration/tests/regression/issues.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -548,4 +548,55 @@ model Group {
})
).resolves.toHaveLength(2);
});

it('issue 627', async () => {
const { prisma, withPolicy } = await loadSchema(
`
model User {
id String @id @default(uuid())
}
abstract model BaseEntityWithTenant {
id String @id @default(uuid())
name String
tenant_id String
tenant tenant? @relation(fields: [tenant_id], references: [id])
@@allow('all', auth().id == tenant_id)
}
model tenant {
id String @id @default(uuid())
equipments Equipment[]
}
model Equipment extends BaseEntityWithTenant {
a String
}
`,
{ logPrismaQuery: true }
);

await prisma.tenant.create({
data: {
id: 'tenant-1',
},
});

const db = withPolicy({ id: 'tenant-1' });
const r = await db.equipment.create({
data: {
name: 'equipment-1',
tenant: {
connect: {
id: 'tenant-1',
},
},
a: 'a',
},
});

console.log(r);
});
});

0 comments on commit 2ef93cb

Please sign in to comment.