This repository was archived by the owner on Mar 1, 2026. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 17
fix(orm): operator "!" should only be applicable to boolean fields #511
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,103 @@ | ||
| import { createPolicyTestClient } from '@zenstackhq/testtools'; | ||
| import { describe, expect, it } from 'vitest'; | ||
|
|
||
| describe('Regression tests for issues 510', () => { | ||
|
ymc9 marked this conversation as resolved.
Outdated
|
||
| it('verifies the issue', async () => { | ||
| const schema = ` | ||
| type ID { | ||
| id String @id @default(nanoid()) | ||
| } | ||
|
|
||
| type Timestamps { | ||
| createdAt DateTime @default(now()) | ||
| updatedAt DateTime @updatedAt | ||
| } | ||
|
|
||
| type Base with ID, Timestamps { | ||
| } | ||
|
|
||
| type AuthInfo { | ||
| id String | ||
| username String | ||
| role Role | ||
|
|
||
| @@auth | ||
| } | ||
|
|
||
| enum Role { | ||
| SUPERADMIN | ||
| ADMIN | ||
| USER | ||
| } | ||
|
|
||
| enum FileStatus { | ||
| PENDING | ||
| UPLOADED | ||
| FAILED | ||
| } | ||
|
|
||
| model User with Base { | ||
| username String @unique | ||
| passwordHash String | ||
| name String | ||
| role Role | ||
|
|
||
| RefreshToken RefreshToken[] | ||
| File File[] | ||
| Post Post[] | ||
|
|
||
| @@allow('all', auth().id == id) | ||
| } | ||
|
|
||
| model File with Timestamps { | ||
| key String @id | ||
|
|
||
| userId String | ||
| User User @relation(fields: [userId], references: [id]) | ||
|
|
||
| originalFilename String | ||
| filename String | ||
| contentType String | ||
| size Int? | ||
| status FileStatus | ||
|
|
||
| Post Post[] | ||
|
|
||
| @@allow('all', auth().id == userId) | ||
| } | ||
|
|
||
| model AuditLog { | ||
| timestamp DateTime @id @default(now()) | ||
|
|
||
| action String | ||
| data Json | ||
|
|
||
| @@deny('all', true) | ||
| } | ||
|
|
||
| model RefreshToken with Base { | ||
| userId String | ||
| User User @relation(fields: [userId], references: [id]) | ||
|
|
||
| revoked Boolean | ||
|
|
||
| @@deny('all', true) | ||
| } | ||
|
|
||
| model Post with Base { | ||
| userId String | ||
| User User @relation(fields: [userId], references: [id]) | ||
|
|
||
| content String | ||
| imageKey String? | ||
| Image File? @relation(fields: [imageKey], references: [key]) | ||
|
|
||
| @@allow('read', true) | ||
| @@allow('create', auth().id == userId && (!Image || auth().id == Image.userId)) | ||
| @@allow('update,delete', auth().id == userId) | ||
| } | ||
| `; | ||
|
|
||
| await expect(createPolicyTestClient(schema)).rejects.toThrow(/operand of "!" must be of Boolean type/); | ||
| }); | ||
| }); | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.