Skip to content

Commit 1bdfbf4

Browse files
authored
fix: support "Unsupported" type of fields in "@@index" (#1902)
1 parent 7fce0f0 commit 1bdfbf4

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

packages/schema/src/language-server/validator/expression-validator.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ export default class ExpressionValidator implements AstValidator<Expression> {
5959
}
6060
}
6161

62-
if (expr.$resolvedType?.decl === 'Unsupported') {
63-
accept('error', 'Field of "Unsupported" type cannot be used in expressions', { node: expr });
64-
}
65-
6662
// extra validations by expression type
6763
switch (expr.$type) {
6864
case 'BinaryExpr':

packages/schema/tests/schema/validation/datamodel-validation.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ describe('Data Model Validation Tests', () => {
7575
@@allow('all', a == 'a')
7676
}
7777
`)
78-
).toMatchObject(errorLike('Field of "Unsupported" type cannot be used in expressions'));
78+
).toMatchObject(errorLike('incompatible operand types'));
7979
});
8080

8181
it('Using `this` in collection predicate', async () => {
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { loadModel, loadSchema } from '@zenstackhq/testtools';
2+
3+
describe('issue 1870', () => {
4+
it('regression', async () => {
5+
await loadModel(
6+
`
7+
model Polygon {
8+
id Int @id @default(autoincrement())
9+
geometry Unsupported("geometry(MultiPolygon, 4326)")
10+
@@index([geometry], name: "parcel_polygon_idx", type: Gist)
11+
}
12+
`
13+
);
14+
});
15+
});

0 commit comments

Comments
 (0)