Skip to content

Commit

Permalink
fix: support "Unsupported" type of fields in "@@index"
Browse files Browse the repository at this point in the history
fixes #1870
  • Loading branch information
ymc9 committed Dec 3, 2024
1 parent 7fce0f0 commit 7824795
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
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)
}
`
);
});
});

0 comments on commit 7824795

Please sign in to comment.