Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support "Unsupported" type of fields in "@@index" #1902

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ export default class ExpressionValidator implements AstValidator<Expression> {
}
}

if (expr.$resolvedType?.decl === 'Unsupported') {
accept('error', 'Field of "Unsupported" type cannot be used in expressions', { node: expr });
}

// extra validations by expression type
switch (expr.$type) {
case 'BinaryExpr':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describe('Data Model Validation Tests', () => {
@@allow('all', a == 'a')
}
`)
).toMatchObject(errorLike('Field of "Unsupported" type cannot be used in expressions'));
).toMatchObject(errorLike('incompatible operand types'));
});

it('Using `this` in collection predicate', async () => {
Expand Down
15 changes: 15 additions & 0 deletions tests/regression/tests/issue-1870.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { loadModel, loadSchema } from '@zenstackhq/testtools';

describe('issue 1870', () => {
it('regression', async () => {
await loadModel(
`
model Polygon {
id Int @id @default(autoincrement())
geometry Unsupported("geometry(MultiPolygon, 4326)")
@@index([geometry], name: "parcel_polygon_idx", type: Gist)
}
`
);
});
});
Loading