File tree Expand file tree Collapse file tree 4 files changed +49
-26
lines changed Expand file tree Collapse file tree 4 files changed +49
-26
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,12 @@ export function isAttributeName(item: unknown): item is AttributeName {
20
20
return isDataModelAttributeName ( item ) || isDataModelFieldAttributeName ( item ) || isInternalAttributeName ( item ) ;
21
21
}
22
22
23
+ export type Boolean = boolean ;
24
+
25
+ export function isBoolean ( item : unknown ) : item is Boolean {
26
+ return typeof item === 'boolean' ;
27
+ }
28
+
23
29
export type BuiltinType = 'BigInt' | 'Boolean' | 'Bytes' | 'DateTime' | 'Decimal' | 'Float' | 'Int' | 'Json' | 'String' ;
24
30
25
31
export function isBuiltinType ( item : unknown ) : item is BuiltinType {
@@ -422,7 +428,7 @@ export function isInvocationExpr(item: unknown): item is InvocationExpr {
422
428
export interface LiteralExpr extends AstNode {
423
429
readonly $container : Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | FieldInitializer | FunctionDecl | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr | UnsupportedFieldType ;
424
430
readonly $type : 'LiteralExpr' ;
425
- value : boolean | number | string
431
+ value : Boolean | number | string
426
432
}
427
433
428
434
export const LiteralExpr = 'LiteralExpr' ;
@@ -856,14 +862,6 @@ export class ZModelAstReflection extends AbstractAstReflection {
856
862
]
857
863
} ;
858
864
}
859
- case 'LiteralExpr' : {
860
- return {
861
- name : 'LiteralExpr' ,
862
- mandatory : [
863
- { name : 'value' , type : 'boolean' }
864
- ]
865
- } ;
866
- }
867
865
case 'Model' : {
868
866
return {
869
867
name : 'Model' ,
Original file line number Diff line number Diff line change @@ -565,7 +565,7 @@ export const ZModelGrammar = (): Grammar => loadedZModelGrammar ?? (loadedZModel
565
565
{
566
566
"$type": "RuleCall",
567
567
"rule": {
568
- "$ref": "#/rules@56 "
568
+ "$ref": "#/rules@55 "
569
569
},
570
570
"arguments": []
571
571
},
@@ -3258,28 +3258,38 @@ export const ZModelGrammar = (): Grammar => loadedZModelGrammar ?? (loadedZModel
3258
3258
"wildcard": false
3259
3259
},
3260
3260
{
3261
- "$type": "TerminalRule ",
3262
- "hidden ": true ,
3263
- "name ": "WS ",
3261
+ "$type": "ParserRule ",
3262
+ "name ": "Boolean" ,
3263
+ "dataType ": "boolean ",
3264
3264
"definition": {
3265
- "$type": "RegexToken",
3266
- "regex": "\\\\s+"
3265
+ "$type": "Alternatives",
3266
+ "elements": [
3267
+ {
3268
+ "$type": "Keyword",
3269
+ "value": "true"
3270
+ },
3271
+ {
3272
+ "$type": "Keyword",
3273
+ "value": "false"
3274
+ }
3275
+ ]
3267
3276
},
3268
- "fragment": false
3277
+ "definesHiddenTokens": false,
3278
+ "entry": false,
3279
+ "fragment": false,
3280
+ "hiddenTokens": [],
3281
+ "parameters": [],
3282
+ "wildcard": false
3269
3283
},
3270
3284
{
3271
3285
"$type": "TerminalRule",
3272
- "name": "BOOLEAN",
3273
- "type": {
3274
- "$type": "ReturnType",
3275
- "name": "boolean"
3276
- },
3286
+ "hidden": true,
3287
+ "name": "WS",
3277
3288
"definition": {
3278
3289
"$type": "RegexToken",
3279
- "regex": "true|false "
3290
+ "regex": "\\\\s+ "
3280
3291
},
3281
- "fragment": false,
3282
- "hidden": false
3292
+ "fragment": false
3283
3293
},
3284
3294
{
3285
3295
"$type": "TerminalRule",
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ Expression:
39
39
LogicalExpr;
40
40
41
41
LiteralExpr:
42
- value=(BOOLEAN | NUMBER | STRING);
42
+ value=(Boolean | NUMBER | STRING);
43
43
44
44
ArrayExpr:
45
45
'[' (items+=Expression (',' items+=Expression)*)? ']';
@@ -255,8 +255,10 @@ ExpressionType returns string:
255
255
BuiltinType returns string:
256
256
'String' | 'Boolean' | 'Int' | 'BigInt' | 'Float' | 'Decimal' | 'DateTime' | 'Json' | 'Bytes';
257
257
258
+ Boolean returns boolean:
259
+ 'true' | 'false';
260
+
258
261
hidden terminal WS: /\s+/;
259
- terminal BOOLEAN returns boolean: /true|false/;
260
262
terminal NULL: 'null';
261
263
terminal THIS: 'this';
262
264
terminal ID: /[_a-zA-Z][\w_]*/;
Original file line number Diff line number Diff line change @@ -496,4 +496,17 @@ describe('Parsing Tests', () => {
496
496
` ;
497
497
await loadModel ( content , false ) ;
498
498
} ) ;
499
+
500
+ it ( 'boolean prefix id' , async ( ) => {
501
+ const content = `
502
+ model trueModel {
503
+ id String @id
504
+ isPublic Boolean @default(false)
505
+ trueText String?
506
+ falseText String?
507
+ @@allow('all', isPublic == true)
508
+ }
509
+ ` ;
510
+ await loadModel ( content , false ) ;
511
+ } ) ;
499
512
} ) ;
You can’t perform that action at this time.
0 commit comments