@surrealdb/lezer 1.0.4 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +2 -2
- package/.turbo/turbo-run-tests.log +13 -4
- package/dist/index.cjs +204 -202
- package/dist/index.js +204 -202
- package/package.json +1 -1
- package/src/parser.js +18 -18
- package/src/parser.terms.js +370 -368
- package/src/surrealql.grammar +69 -55
- package/src/tokens.js +2 -0
- package/test/misc/comments.txt +5 -5
- package/test/misc/functions.txt +3 -3
- package/test/misc/identifiers.txt +4 -4
- package/test/misc/javascript.txt +1 -1
- package/test/misc/operators.txt +10 -10
- package/test/misc/subqueries.txt +1 -1
- package/test/statements/create.txt +2 -2
- package/test/statements/define.txt +60 -4
- package/test/statements/delete.txt +1 -1
- package/test/statements/for.txt +1 -1
- package/test/statements/if-else.txt +6 -6
- package/test/statements/insert.txt +2 -2
- package/test/statements/let.txt +3 -3
- package/test/statements/live.txt +1 -1
- package/test/statements/return.txt +2 -2
- package/test/statements/select.txt +8 -8
- package/test/statements/show.txt +2 -2
- package/test/statements/update.txt +15 -7
- package/test/statements/upsert.txt +3 -3
- package/test/values/arrays.txt +5 -5
- package/test/values/closures.txt +3 -3
- package/test/values/format-strings.txt +3 -3
- package/test/values/geometries.txt +3 -3
- package/test/values/idioms.txt +8 -8
- package/test/values/numbers.txt +21 -9
- package/test/values/objects.txt +6 -6
- package/test/values/ranges.txt +3 -3
- package/test/values/record-ids.txt +2 -2
- package/test/values/sets.txt +3 -3
package/src/surrealql.grammar
CHANGED
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
filter
|
|
33
33
|
for
|
|
34
34
|
clause
|
|
35
|
+
flexibleAfter
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
expressions {
|
|
@@ -63,6 +64,7 @@ anyKeyword {
|
|
|
63
64
|
asc |
|
|
64
65
|
assert |
|
|
65
66
|
at |
|
|
67
|
+
async |
|
|
66
68
|
authenticate |
|
|
67
69
|
auto |
|
|
68
70
|
begin |
|
|
@@ -336,6 +338,7 @@ defineEventOptions {
|
|
|
336
338
|
value
|
|
337
339
|
} |
|
|
338
340
|
ThenClause {
|
|
341
|
+
async?
|
|
339
342
|
then
|
|
340
343
|
commaSep<(SubQuery | Block)>
|
|
341
344
|
} |
|
|
@@ -778,7 +781,7 @@ ShowStatement {
|
|
|
778
781
|
show changes for table
|
|
779
782
|
Ident
|
|
780
783
|
( since String )?
|
|
781
|
-
( limit
|
|
784
|
+
( limit Number )?
|
|
782
785
|
}
|
|
783
786
|
|
|
784
787
|
// Sleep statement
|
|
@@ -816,30 +819,34 @@ RebuildStatement[since=1_5_0] {
|
|
|
816
819
|
|
|
817
820
|
// Values
|
|
818
821
|
|
|
819
|
-
|
|
822
|
+
computedValue[@isGroup=Value] {
|
|
820
823
|
String |
|
|
821
824
|
prefixedString |
|
|
822
|
-
|
|
823
|
-
number |
|
|
825
|
+
Number |
|
|
824
826
|
true |
|
|
825
827
|
false |
|
|
826
828
|
null |
|
|
827
829
|
none |
|
|
828
|
-
Regex |
|
|
829
|
-
VariableName |
|
|
830
|
-
Ident[@dynamicPrecedence=-1] { rawident } |
|
|
831
830
|
Array |
|
|
832
831
|
Set |
|
|
833
832
|
RecordId |
|
|
833
|
+
Object |
|
|
834
|
+
Duration |
|
|
835
|
+
Point { "(" Number "," Number ")" }
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
baseValue[@isGroup=Value] {
|
|
839
|
+
computedValue |
|
|
840
|
+
FormatString |
|
|
841
|
+
Regex |
|
|
842
|
+
VariableName |
|
|
843
|
+
Ident[@dynamicPrecedence=-1] { rawident } |
|
|
834
844
|
FunctionJs |
|
|
835
845
|
FunctionCall |
|
|
836
846
|
SubQuery |
|
|
837
847
|
Block |
|
|
838
848
|
Closure |
|
|
839
|
-
|
|
840
|
-
TypeCast |
|
|
841
|
-
Duration |
|
|
842
|
-
Point { "(" number "," number ")" }
|
|
849
|
+
TypeCast
|
|
843
850
|
}
|
|
844
851
|
|
|
845
852
|
value[@isGroup=Value] {
|
|
@@ -868,7 +875,12 @@ Range[since=2_0_0] {
|
|
|
868
875
|
}
|
|
869
876
|
|
|
870
877
|
Idiom {
|
|
871
|
-
Ident
|
|
878
|
+
Ident idiomPart*
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
idiomPart {
|
|
882
|
+
"." ( Ident | AnyStar ) |
|
|
883
|
+
"[" AnyStar "]"
|
|
872
884
|
}
|
|
873
885
|
|
|
874
886
|
Path {
|
|
@@ -940,11 +952,11 @@ Recurse[since=2_1_0] {
|
|
|
940
952
|
}
|
|
941
953
|
|
|
942
954
|
RecurseRange {
|
|
943
|
-
|
|
955
|
+
Number |
|
|
944
956
|
rangeOpOpenBoth |
|
|
945
|
-
|
|
946
|
-
rangeOpOpenLeft
|
|
947
|
-
|
|
957
|
+
Number rangeOpOpenRight |
|
|
958
|
+
rangeOpOpenLeft Number |
|
|
959
|
+
Number rangeOp Number
|
|
948
960
|
}
|
|
949
961
|
|
|
950
962
|
RecurseOptions[since=2_2_0] {
|
|
@@ -1005,7 +1017,7 @@ RecordTbIdent {
|
|
|
1005
1017
|
bracketIdent
|
|
1006
1018
|
}
|
|
1007
1019
|
|
|
1008
|
-
// Ideally we match "
|
|
1020
|
+
// Ideally we match "Number" here, but I cannot for the life of me get it to
|
|
1009
1021
|
// fall back to numberident after. This will suffice for now.
|
|
1010
1022
|
RecordIdIdent {
|
|
1011
1023
|
numberident |
|
|
@@ -1092,7 +1104,7 @@ FieldAssignment {
|
|
|
1092
1104
|
// Clauses
|
|
1093
1105
|
|
|
1094
1106
|
MergeClause {
|
|
1095
|
-
merge
|
|
1107
|
+
merge value
|
|
1096
1108
|
}
|
|
1097
1109
|
|
|
1098
1110
|
PatchClause {
|
|
@@ -1199,15 +1211,15 @@ SearchAnalyzerClause {
|
|
|
1199
1211
|
)*
|
|
1200
1212
|
}
|
|
1201
1213
|
|
|
1202
|
-
Bm25Clause { bm25 ( "("
|
|
1203
|
-
DocIdsCacheClause { doc_ids_cache
|
|
1204
|
-
DocIdsOrderClause { doc_ids_order
|
|
1205
|
-
DocLenghtsCacheClause { doc_lengths_cache
|
|
1206
|
-
DocLenghtsOrderClause { doc_lengths_order
|
|
1207
|
-
PostingsCacheClause { postings_cache
|
|
1208
|
-
PostingsOrderClause { postings_order
|
|
1209
|
-
TermsCacheClause { terms_cache
|
|
1210
|
-
TermsOrderClause { terms_order
|
|
1214
|
+
Bm25Clause { bm25 ( "(" Number "," Number ")")? }
|
|
1215
|
+
DocIdsCacheClause { doc_ids_cache Number }
|
|
1216
|
+
DocIdsOrderClause { doc_ids_order Number }
|
|
1217
|
+
DocLenghtsCacheClause { doc_lengths_cache Number }
|
|
1218
|
+
DocLenghtsOrderClause { doc_lengths_order Number }
|
|
1219
|
+
PostingsCacheClause { postings_cache Number }
|
|
1220
|
+
PostingsOrderClause { postings_order Number }
|
|
1221
|
+
TermsCacheClause { terms_cache Number }
|
|
1222
|
+
TermsOrderClause { terms_order Number }
|
|
1211
1223
|
|
|
1212
1224
|
MtreeClause[since=1_3_0] {
|
|
1213
1225
|
mtree
|
|
@@ -1222,7 +1234,7 @@ MtreeClause[since=1_3_0] {
|
|
|
1222
1234
|
)*
|
|
1223
1235
|
}
|
|
1224
1236
|
|
|
1225
|
-
MtreeCacheClause { mtree_cache
|
|
1237
|
+
MtreeCacheClause { mtree_cache Number }
|
|
1226
1238
|
MtreeDistClause { dist ( Distance ) }
|
|
1227
1239
|
|
|
1228
1240
|
HnswClause[since=1_5_0] {
|
|
@@ -1241,14 +1253,14 @@ IndexDimensionClause
|
|
|
1241
1253
|
)*
|
|
1242
1254
|
}
|
|
1243
1255
|
|
|
1244
|
-
HnswDistClause { dist ( Distance | ( minkowski
|
|
1256
|
+
HnswDistClause { dist ( Distance | ( minkowski Number )) }
|
|
1245
1257
|
|
|
1246
|
-
IndexDimensionClause { dimension
|
|
1247
|
-
IndexCapacityClause { capacity
|
|
1248
|
-
IndexLmClause { lm
|
|
1249
|
-
IndexM0Clause { m0
|
|
1250
|
-
IndexMClause { m
|
|
1251
|
-
IndexEfcClause { efc
|
|
1258
|
+
IndexDimensionClause { dimension Number }
|
|
1259
|
+
IndexCapacityClause { capacity Number }
|
|
1260
|
+
IndexLmClause { lm Number }
|
|
1261
|
+
IndexM0Clause { m0 Number }
|
|
1262
|
+
IndexMClause { m Number }
|
|
1263
|
+
IndexEfcClause { efc Number }
|
|
1252
1264
|
IndexExtendCandidatesClause { extend_candidates }
|
|
1253
1265
|
IndexKeepPrunedConnectionsClause { keep_pruned_connections }
|
|
1254
1266
|
|
|
@@ -1304,19 +1316,19 @@ TempfilesClause[since=2_0_0] {
|
|
|
1304
1316
|
|
|
1305
1317
|
FetchClause {
|
|
1306
1318
|
fetch
|
|
1307
|
-
commaSep<
|
|
1319
|
+
commaSep<Idiom>
|
|
1308
1320
|
}
|
|
1309
1321
|
|
|
1310
1322
|
StartClause {
|
|
1311
1323
|
start
|
|
1312
1324
|
at?
|
|
1313
|
-
(
|
|
1325
|
+
(Number | VariableName)
|
|
1314
1326
|
}
|
|
1315
1327
|
|
|
1316
1328
|
LimitClause {
|
|
1317
1329
|
limit
|
|
1318
1330
|
by?
|
|
1319
|
-
(
|
|
1331
|
+
(Number | VariableName)
|
|
1320
1332
|
}
|
|
1321
1333
|
|
|
1322
1334
|
LimitStartComboClause {
|
|
@@ -1380,9 +1392,9 @@ FunctionClause {
|
|
|
1380
1392
|
}
|
|
1381
1393
|
|
|
1382
1394
|
TypeClause {
|
|
1383
|
-
flexible
|
|
1384
|
-
typeKeyword
|
|
1385
|
-
type
|
|
1395
|
+
( flexible typeKeyword type ) |
|
|
1396
|
+
( typeKeyword type !flexibleAfter flexible ) |
|
|
1397
|
+
( typeKeyword type )
|
|
1386
1398
|
}
|
|
1387
1399
|
|
|
1388
1400
|
ReadonlyClause[since=1_2_0] {
|
|
@@ -1465,7 +1477,7 @@ BackendClause {
|
|
|
1465
1477
|
// Support
|
|
1466
1478
|
|
|
1467
1479
|
AnalyzerFilters {
|
|
1468
|
-
Filter ("(" (
|
|
1480
|
+
Filter ("(" (Number "," Number | Ident) ")")?
|
|
1469
1481
|
}
|
|
1470
1482
|
|
|
1471
1483
|
Order {
|
|
@@ -1488,11 +1500,11 @@ inclusivePredicate {
|
|
|
1488
1500
|
|
|
1489
1501
|
LiteralType[since=2_0_0] {
|
|
1490
1502
|
String |
|
|
1491
|
-
|
|
1503
|
+
Number |
|
|
1492
1504
|
Duration |
|
|
1493
1505
|
ArrayType { "[" commaSep<type> "]" } |
|
|
1494
1506
|
ObjectType { objectOpen ObjectTypeContent? "}" }
|
|
1495
|
-
// TODO support
|
|
1507
|
+
// TODO support Number and duration types
|
|
1496
1508
|
}
|
|
1497
1509
|
|
|
1498
1510
|
singleType {
|
|
@@ -1527,7 +1539,7 @@ Ident {
|
|
|
1527
1539
|
tickIdent
|
|
1528
1540
|
}
|
|
1529
1541
|
|
|
1530
|
-
|
|
1542
|
+
Number { ("-" | "+")? (Int | Float | Decimal) }
|
|
1531
1543
|
|
|
1532
1544
|
Operator {
|
|
1533
1545
|
binaryOperator |
|
|
@@ -1536,11 +1548,11 @@ Operator {
|
|
|
1536
1548
|
is | ( is opNot ) |
|
|
1537
1549
|
in | ( opNot opIn ) |
|
|
1538
1550
|
|
|
1539
|
-
( "@"
|
|
1551
|
+
( "@" Number "@" ) |
|
|
1540
1552
|
(
|
|
1541
1553
|
"<|"
|
|
1542
|
-
|
|
1543
|
-
( "," (
|
|
1554
|
+
Number
|
|
1555
|
+
( "," ( Number | Distance | ( minkowski Number ) ) )
|
|
1544
1556
|
"|>"
|
|
1545
1557
|
)
|
|
1546
1558
|
}
|
|
@@ -1589,12 +1601,13 @@ Operator {
|
|
|
1589
1601
|
CommentResult[@name=Comment,closedBy=CommentResultClose] { "-------- Query" ![\n]* }
|
|
1590
1602
|
|
|
1591
1603
|
// Numbers
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1604
|
+
digitSeq { @digit+ ("_" @digit+)* }
|
|
1605
|
+
Int { digitSeq }
|
|
1606
|
+
frac { '.' digitSeq }
|
|
1607
|
+
exp { $[eE] $[+\-]? digitSeq }
|
|
1608
|
+
Float { (digitSeq "f") | (digitSeq (frac exp? | exp) "f"?) | "Infinity" | "NaN" }
|
|
1609
|
+
Decimal { digitSeq frac? exp? "dec" }
|
|
1610
|
+
VersionNumber { digitSeq ("." digitSeq ("." digitSeq)?)? }
|
|
1598
1611
|
|
|
1599
1612
|
String { "'" (!['\\] | "\\" _)* "'" | '"' (!["\\] | "\\" _)* '"' }
|
|
1600
1613
|
prefixedString[@name=String] { $[rudbf] String }
|
|
@@ -1627,7 +1640,7 @@ Operator {
|
|
|
1627
1640
|
Regex { "/" (![/\\\n[] | "\\" ![\n] | "[" (![\n\\\]] | "\\" ![\n])* "]")+ ("/" $[dgimsuvy]*)? }
|
|
1628
1641
|
|
|
1629
1642
|
durationUnit { "ns" | "us" | "µs" | "ms" | "s" | "m" | "h" | "d" | "w" | "y"}
|
|
1630
|
-
DurationPart {
|
|
1643
|
+
DurationPart { digitSeq " "* durationUnit }
|
|
1631
1644
|
|
|
1632
1645
|
@precedence { CommentResult Comment Int "-" }
|
|
1633
1646
|
@precedence { Comment binaryOperator }
|
|
@@ -1689,6 +1702,7 @@ piped<content> {
|
|
|
1689
1702
|
asc [@name=Keyword],
|
|
1690
1703
|
assert [@name=Keyword],
|
|
1691
1704
|
at [@name=Keyword],
|
|
1705
|
+
async [@name=Keyword],
|
|
1692
1706
|
authenticate [@name=Keyword],
|
|
1693
1707
|
auto [@name=Keyword],
|
|
1694
1708
|
backend [@name=Keyword],
|
package/src/tokens.js
CHANGED
package/test/misc/comments.txt
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
==>
|
|
7
7
|
|
|
8
|
-
SurrealQL(Comment,Int)
|
|
8
|
+
SurrealQL(Comment,Number(Int))
|
|
9
9
|
|
|
10
10
|
# Dash comment
|
|
11
11
|
|
|
@@ -14,7 +14,7 @@ SurrealQL(Comment,Int)
|
|
|
14
14
|
|
|
15
15
|
==>
|
|
16
16
|
|
|
17
|
-
SurrealQL(Comment,Int)
|
|
17
|
+
SurrealQL(Comment,Number(Int))
|
|
18
18
|
|
|
19
19
|
# Slash comment
|
|
20
20
|
|
|
@@ -23,7 +23,7 @@ SurrealQL(Comment,Int)
|
|
|
23
23
|
|
|
24
24
|
==>
|
|
25
25
|
|
|
26
|
-
SurrealQL(Comment,Int)
|
|
26
|
+
SurrealQL(Comment,Number(Int))
|
|
27
27
|
|
|
28
28
|
# Block comment
|
|
29
29
|
|
|
@@ -33,7 +33,7 @@ SurrealQL(Comment,Int)
|
|
|
33
33
|
|
|
34
34
|
==>
|
|
35
35
|
|
|
36
|
-
SurrealQL(BinaryExpression(Int,BlockComment,Operator,Int))
|
|
36
|
+
SurrealQL(BinaryExpression(Number(Int),BlockComment,Operator,Number(Int)))
|
|
37
37
|
|
|
38
38
|
# Block comment standalone
|
|
39
39
|
|
|
@@ -41,4 +41,4 @@ SurrealQL(BinaryExpression(Int,BlockComment,Operator,Int))
|
|
|
41
41
|
|
|
42
42
|
==>
|
|
43
43
|
|
|
44
|
-
SurrealQL(BlockComment,Int)
|
|
44
|
+
SurrealQL(BlockComment,Number(Int))
|
package/test/misc/functions.txt
CHANGED
|
@@ -12,7 +12,7 @@ fn::one::two(1, a)
|
|
|
12
12
|
|
|
13
13
|
==>
|
|
14
14
|
|
|
15
|
-
SurrealQL(FunctionCall(FunctionName,ArgumentList(Int,Ident)))
|
|
15
|
+
SurrealQL(FunctionCall(FunctionName,ArgumentList(Number(Int),Ident)))
|
|
16
16
|
|
|
17
17
|
# Rand function
|
|
18
18
|
|
|
@@ -20,7 +20,7 @@ rand(3)
|
|
|
20
20
|
|
|
21
21
|
==>
|
|
22
22
|
|
|
23
|
-
SurrealQL(FunctionCall(FunctionName,ArgumentList(Int)))
|
|
23
|
+
SurrealQL(FunctionCall(FunctionName,ArgumentList(Number(Int))))
|
|
24
24
|
|
|
25
25
|
# Count function
|
|
26
26
|
|
|
@@ -60,4 +60,4 @@ $func(1)
|
|
|
60
60
|
|
|
61
61
|
==>
|
|
62
62
|
|
|
63
|
-
SurrealQL(FunctionCall(VariableName,ArgumentList(Int)))
|
|
63
|
+
SurrealQL(FunctionCall(VariableName,ArgumentList(Number(Int))))
|
|
@@ -16,7 +16,7 @@ create bla set true = 1, false = 2, null = 3, none = 4
|
|
|
16
16
|
SurrealQL(CreateStatement(
|
|
17
17
|
Keyword,Ident,
|
|
18
18
|
SetClause( Keyword,
|
|
19
|
-
FieldAssignment(Ident,Operator,Int),
|
|
20
|
-
FieldAssignment(Ident,Operator,Int),
|
|
21
|
-
FieldAssignment(Ident,Operator,Int),
|
|
22
|
-
FieldAssignment(Ident,Operator,Int))))
|
|
19
|
+
FieldAssignment(Ident,Operator,Number(Int)),
|
|
20
|
+
FieldAssignment(Ident,Operator,Number(Int)),
|
|
21
|
+
FieldAssignment(Ident,Operator,Number(Int)),
|
|
22
|
+
FieldAssignment(Ident,Operator,Number(Int)))))
|
package/test/misc/javascript.txt
CHANGED
|
@@ -12,7 +12,7 @@ function(123, 1d2h) {
|
|
|
12
12
|
SurrealQL(
|
|
13
13
|
FunctionJs(
|
|
14
14
|
FunctionName,
|
|
15
|
-
ArgumentList(Int,Duration(DurationPart,DurationPart)),
|
|
15
|
+
ArgumentList(Number(Int),Duration(DurationPart,DurationPart)),
|
|
16
16
|
JavaScriptBlock(BraceOpen,JavaScriptContent,BraceClose)
|
|
17
17
|
)
|
|
18
18
|
)
|
package/test/misc/operators.txt
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
==>
|
|
6
6
|
|
|
7
|
-
SurrealQL(BinaryExpression(Int,Operator,Int))
|
|
7
|
+
SurrealQL(BinaryExpression(Number(Int),Operator,Number(Int)))
|
|
8
8
|
|
|
9
9
|
# Subtraction
|
|
10
10
|
|
|
@@ -12,7 +12,7 @@ SurrealQL(BinaryExpression(Int,Operator,Int))
|
|
|
12
12
|
|
|
13
13
|
==>
|
|
14
14
|
|
|
15
|
-
SurrealQL(BinaryExpression(Int,Operator,Int))
|
|
15
|
+
SurrealQL(BinaryExpression(Number(Int),Operator,Number(Int)))
|
|
16
16
|
|
|
17
17
|
# Multiplication
|
|
18
18
|
|
|
@@ -20,7 +20,7 @@ SurrealQL(BinaryExpression(Int,Operator,Int))
|
|
|
20
20
|
|
|
21
21
|
==>
|
|
22
22
|
|
|
23
|
-
SurrealQL(BinaryExpression(Int,Operator,Int))
|
|
23
|
+
SurrealQL(BinaryExpression(Number(Int),Operator,Number(Int)))
|
|
24
24
|
|
|
25
25
|
# Division
|
|
26
26
|
|
|
@@ -28,7 +28,7 @@ SurrealQL(BinaryExpression(Int,Operator,Int))
|
|
|
28
28
|
|
|
29
29
|
==>
|
|
30
30
|
|
|
31
|
-
SurrealQL(BinaryExpression(Int,Operator,Int))
|
|
31
|
+
SurrealQL(BinaryExpression(Number(Int),Operator,Number(Int)))
|
|
32
32
|
|
|
33
33
|
# Power
|
|
34
34
|
|
|
@@ -36,7 +36,7 @@ SurrealQL(BinaryExpression(Int,Operator,Int))
|
|
|
36
36
|
|
|
37
37
|
==>
|
|
38
38
|
|
|
39
|
-
SurrealQL(BinaryExpression(Int,Operator,Int))
|
|
39
|
+
SurrealQL(BinaryExpression(Number(Int),Operator,Number(Int)))
|
|
40
40
|
|
|
41
41
|
# Equality
|
|
42
42
|
|
|
@@ -178,7 +178,7 @@ SurrealQL(BinaryExpression(Ident,Operator,Ident))
|
|
|
178
178
|
|
|
179
179
|
==>
|
|
180
180
|
|
|
181
|
-
SurrealQL(BinaryExpression(Int,Operator,Int))
|
|
181
|
+
SurrealQL(BinaryExpression(Number(Int),Operator,Number(Int)))
|
|
182
182
|
|
|
183
183
|
# Unicode division
|
|
184
184
|
|
|
@@ -186,7 +186,7 @@ SurrealQL(BinaryExpression(Int,Operator,Int))
|
|
|
186
186
|
|
|
187
187
|
==>
|
|
188
188
|
|
|
189
|
-
SurrealQL(BinaryExpression(Int,Operator,Int))
|
|
189
|
+
SurrealQL(BinaryExpression(Number(Int),Operator,Number(Int)))
|
|
190
190
|
|
|
191
191
|
# Matches operator with distance
|
|
192
192
|
|
|
@@ -194,7 +194,7 @@ x @1@ y
|
|
|
194
194
|
|
|
195
195
|
==>
|
|
196
196
|
|
|
197
|
-
SurrealQL(BinaryExpression(Ident,Operator(Int),Ident))
|
|
197
|
+
SurrealQL(BinaryExpression(Ident,Operator(Number(Int)),Ident))
|
|
198
198
|
|
|
199
199
|
# Addition assignment in expression
|
|
200
200
|
|
|
@@ -202,7 +202,7 @@ a += 1
|
|
|
202
202
|
|
|
203
203
|
==>
|
|
204
204
|
|
|
205
|
-
SurrealQL(BinaryExpression(Ident,Operator,Int))
|
|
205
|
+
SurrealQL(BinaryExpression(Ident,Operator,Number(Int)))
|
|
206
206
|
|
|
207
207
|
# Subtraction assignment in expression
|
|
208
208
|
|
|
@@ -210,4 +210,4 @@ a -= 1
|
|
|
210
210
|
|
|
211
211
|
==>
|
|
212
212
|
|
|
213
|
-
SurrealQL(BinaryExpression(Ident,Operator,Int))
|
|
213
|
+
SurrealQL(BinaryExpression(Ident,Operator,Number(Int)))
|
package/test/misc/subqueries.txt
CHANGED
|
@@ -20,7 +20,7 @@ CREATE person SET name = "Tobie", age = 30
|
|
|
20
20
|
|
|
21
21
|
==>
|
|
22
22
|
|
|
23
|
-
SurrealQL(CreateStatement(Keyword,Ident,SetClause(Keyword,FieldAssignment(Ident,Operator,String),FieldAssignment(Ident,Operator,Int))))
|
|
23
|
+
SurrealQL(CreateStatement(Keyword,Ident,SetClause(Keyword,FieldAssignment(Ident,Operator,String),FieldAssignment(Ident,Operator,Number(Int)))))
|
|
24
24
|
|
|
25
25
|
# Create with CONTENT
|
|
26
26
|
|
|
@@ -28,7 +28,7 @@ CREATE person CONTENT {name: "Tobie", age: 30}
|
|
|
28
28
|
|
|
29
29
|
==>
|
|
30
30
|
|
|
31
|
-
SurrealQL(CreateStatement(Keyword,Ident,ContentClause(Keyword,Object(BraceOpen,ObjectContent(ObjectProperty(ObjectKey(KeyName),Colon,String),ObjectProperty(ObjectKey(KeyName),Colon,Int)),BraceClose))))
|
|
31
|
+
SurrealQL(CreateStatement(Keyword,Ident,ContentClause(Keyword,Object(BraceOpen,ObjectContent(ObjectProperty(ObjectKey(KeyName),Colon,String),ObjectProperty(ObjectKey(KeyName),Colon,Number(Int))),BraceClose))))
|
|
32
32
|
|
|
33
33
|
# Create with RETURN fields
|
|
34
34
|
|
|
@@ -46,6 +46,14 @@ DEFINE EVENT myevent ON TABLE person WHEN $event = "CREATE" THEN (CREATE log)
|
|
|
46
46
|
|
|
47
47
|
SurrealQL(DefineStatement(Keyword,Keyword,Ident,OnTableClause(Keyword,Keyword,Ident),WhenClause(Keyword,BinaryExpression(VariableName,Operator,String)),ThenClause(Keyword,SubQuery(CreateStatement(Keyword,Ident)))))
|
|
48
48
|
|
|
49
|
+
# Define event with async
|
|
50
|
+
|
|
51
|
+
DEFINE EVENT e ON TABLE file WHEN $event = 'DELETE' ASYNC THEN { };
|
|
52
|
+
|
|
53
|
+
==>
|
|
54
|
+
|
|
55
|
+
SurrealQL(DefineStatement(Keyword,Keyword,Ident,OnTableClause(Keyword,Keyword,Ident),WhenClause(Keyword,BinaryExpression(VariableName,Operator,String)),ThenClause(Keyword,Keyword,Block(BraceOpen,BraceClose))))
|
|
56
|
+
|
|
49
57
|
# Define field
|
|
50
58
|
|
|
51
59
|
DEFINE FIELD name ON TABLE person TYPE string
|
|
@@ -60,7 +68,7 @@ DEFINE FIELD age ON TABLE person TYPE number DEFAULT 0
|
|
|
60
68
|
|
|
61
69
|
==>
|
|
62
70
|
|
|
63
|
-
SurrealQL(DefineStatement(Keyword,Keyword,Idiom(Ident),OnTableClause(Keyword,Keyword,Ident),TypeClause(Keyword,TypeName),DefaultClause(Keyword,DefaultAlways,Int)))
|
|
71
|
+
SurrealQL(DefineStatement(Keyword,Keyword,Idiom(Ident),OnTableClause(Keyword,Keyword,Ident),TypeClause(Keyword,TypeName),DefaultClause(Keyword,DefaultAlways,Number(Int))))
|
|
64
72
|
|
|
65
73
|
# Define field with assert
|
|
66
74
|
|
|
@@ -86,6 +94,22 @@ DEFINE FIELD data ON TABLE person FLEXIBLE TYPE object
|
|
|
86
94
|
|
|
87
95
|
SurrealQL(DefineStatement(Keyword,Keyword,Idiom(Ident),OnTableClause(Keyword,Keyword,Ident),TypeClause(Keyword,Keyword,TypeName)))
|
|
88
96
|
|
|
97
|
+
# Define field with flexible after type clause
|
|
98
|
+
|
|
99
|
+
DEFINE FIELD metadata ON TABLE user TYPE object FLEXIBLE
|
|
100
|
+
|
|
101
|
+
==>
|
|
102
|
+
|
|
103
|
+
SurrealQL(DefineStatement(Keyword,Keyword,Idiom(Ident),OnTableClause(Keyword,Keyword,Ident),TypeClause(Keyword,TypeName,Keyword)))
|
|
104
|
+
|
|
105
|
+
# Define field flexible after parameterized object type
|
|
106
|
+
|
|
107
|
+
DEFINE FIELD alternatives ON file TYPE option<object> FLEXIBLE
|
|
108
|
+
|
|
109
|
+
==>
|
|
110
|
+
|
|
111
|
+
SurrealQL(DefineStatement(Keyword,Keyword,Idiom(Ident),OnTableClause(Keyword,Ident),TypeClause(Keyword,ParameterizedType(TypeName,"<",TypeName,">"),Keyword)))
|
|
112
|
+
|
|
89
113
|
# Define field with permissions
|
|
90
114
|
|
|
91
115
|
DEFINE FIELD secret ON TABLE person TYPE string PERMISSIONS FOR select, create WHERE $auth.admin = true
|
|
@@ -110,6 +134,30 @@ DEFINE FIELD fullname ON TABLE person COMPUTED $value.first + " " + $value.last
|
|
|
110
134
|
|
|
111
135
|
SurrealQL(DefineStatement(Keyword,Keyword,Idiom(Ident),OnTableClause(Keyword,Keyword,Ident),ComputedClause(Keyword,BinaryExpression(BinaryExpression(Path(VariableName,Subscript(Ident)),Operator,String),Operator,Path(VariableName,Subscript(Ident))))))
|
|
112
136
|
|
|
137
|
+
# Define field on array items
|
|
138
|
+
|
|
139
|
+
DEFINE FIELD children.* ON parent TYPE record<child> PERMISSIONS FULL
|
|
140
|
+
|
|
141
|
+
==>
|
|
142
|
+
|
|
143
|
+
SurrealQL(DefineStatement(Keyword,Keyword,Idiom(Ident,Any),OnTableClause(Keyword,Ident),TypeClause(Keyword,ParameterizedType(TypeName,"<",TypeName,">")),PermissionsForClause(Keyword,Literal)))
|
|
144
|
+
|
|
145
|
+
# Define field on array items with bracket wildcard
|
|
146
|
+
|
|
147
|
+
DEFINE FIELD tags[*] ON TABLE person TYPE string
|
|
148
|
+
|
|
149
|
+
==>
|
|
150
|
+
|
|
151
|
+
SurrealQL(DefineStatement(Keyword,Keyword,Idiom(Ident,"[",Any,"]"),OnTableClause(Keyword,Keyword,Ident),TypeClause(Keyword,TypeName)))
|
|
152
|
+
|
|
153
|
+
# Define field nested below array items
|
|
154
|
+
|
|
155
|
+
DEFINE FIELD comments.*.title ON TABLE post TYPE string
|
|
156
|
+
|
|
157
|
+
==>
|
|
158
|
+
|
|
159
|
+
SurrealQL(DefineStatement(Keyword,Keyword,Idiom(Ident,Any,Ident),OnTableClause(Keyword,Keyword,Ident),TypeClause(Keyword,TypeName)))
|
|
160
|
+
|
|
113
161
|
# Define index unique
|
|
114
162
|
|
|
115
163
|
DEFINE INDEX idx_email ON TABLE person FIELDS email UNIQUE
|
|
@@ -118,6 +166,14 @@ DEFINE INDEX idx_email ON TABLE person FIELDS email UNIQUE
|
|
|
118
166
|
|
|
119
167
|
SurrealQL(DefineStatement(Keyword,Keyword,Ident,OnTableClause(Keyword,Keyword,Ident),FieldsColumnsClause(Keyword,Idiom(Ident)),IndexClause(UniqueClause(Keyword))))
|
|
120
168
|
|
|
169
|
+
# Define index on array items
|
|
170
|
+
|
|
171
|
+
DEFINE INDEX idx_tags ON TABLE person FIELDS tags.* UNIQUE
|
|
172
|
+
|
|
173
|
+
==>
|
|
174
|
+
|
|
175
|
+
SurrealQL(DefineStatement(Keyword,Keyword,Ident,OnTableClause(Keyword,Keyword,Ident),FieldsColumnsClause(Keyword,Idiom(Ident,Any)),IndexClause(UniqueClause(Keyword))))
|
|
176
|
+
|
|
121
177
|
# Define index search analyzer
|
|
122
178
|
|
|
123
179
|
DEFINE INDEX idx_search ON TABLE person FIELDS name SEARCH ANALYZER my_analyzer BM25
|
|
@@ -132,7 +188,7 @@ DEFINE INDEX idx_vec ON TABLE person FIELDS embedding MTREE DIMENSION 3
|
|
|
132
188
|
|
|
133
189
|
==>
|
|
134
190
|
|
|
135
|
-
SurrealQL(DefineStatement(Keyword,Keyword,Ident,OnTableClause(Keyword,Keyword,Ident),FieldsColumnsClause(Keyword,Idiom(Ident)),IndexClause(MtreeClause(Keyword,IndexDimensionClause(Keyword,Int)))))
|
|
191
|
+
SurrealQL(DefineStatement(Keyword,Keyword,Ident,OnTableClause(Keyword,Keyword,Ident),FieldsColumnsClause(Keyword,Idiom(Ident)),IndexClause(MtreeClause(Keyword,IndexDimensionClause(Keyword,Number(Int))))))
|
|
136
192
|
|
|
137
193
|
# Define index hnsw
|
|
138
194
|
|
|
@@ -140,7 +196,7 @@ DEFINE INDEX idx_vec ON TABLE person FIELDS embedding HNSW DIMENSION 3
|
|
|
140
196
|
|
|
141
197
|
==>
|
|
142
198
|
|
|
143
|
-
SurrealQL(DefineStatement(Keyword,Keyword,Ident,OnTableClause(Keyword,Keyword,Ident),FieldsColumnsClause(Keyword,Idiom(Ident)),IndexClause(HnswClause(Keyword,IndexDimensionClause(Keyword,Int)))))
|
|
199
|
+
SurrealQL(DefineStatement(Keyword,Keyword,Ident,OnTableClause(Keyword,Keyword,Ident),FieldsColumnsClause(Keyword,Idiom(Ident)),IndexClause(HnswClause(Keyword,IndexDimensionClause(Keyword,Number(Int))))))
|
|
144
200
|
|
|
145
201
|
# Define function
|
|
146
202
|
|
|
@@ -222,7 +278,7 @@ DEFINE TABLE adult AS SELECT * FROM person WHERE age > 18
|
|
|
222
278
|
|
|
223
279
|
==>
|
|
224
280
|
|
|
225
|
-
SurrealQL(DefineStatement(Keyword,Keyword,Ident,TableViewClause(Keyword,Keyword,Any,Keyword,Ident,WhereClause(Keyword,BinaryExpression(Ident,Operator,Int)))))
|
|
281
|
+
SurrealQL(DefineStatement(Keyword,Keyword,Ident,TableViewClause(Keyword,Keyword,Any,Keyword,Ident,WhereClause(Keyword,BinaryExpression(Ident,Operator,Number(Int))))))
|
|
226
282
|
|
|
227
283
|
# Define table with changefeed
|
|
228
284
|
|
|
@@ -20,7 +20,7 @@ DELETE person WHERE age < 18
|
|
|
20
20
|
|
|
21
21
|
==>
|
|
22
22
|
|
|
23
|
-
SurrealQL(DeleteStatement(Keyword,Ident,WhereClause(Keyword,BinaryExpression(Ident,Operator,Int))))
|
|
23
|
+
SurrealQL(DeleteStatement(Keyword,Ident,WhereClause(Keyword,BinaryExpression(Ident,Operator,Number(Int)))))
|
|
24
24
|
|
|
25
25
|
# Delete with RETURN BEFORE
|
|
26
26
|
|
package/test/statements/for.txt
CHANGED
|
@@ -6,7 +6,7 @@ FOR $item IN [1, 2, 3] {
|
|
|
6
6
|
|
|
7
7
|
==>
|
|
8
8
|
|
|
9
|
-
SurrealQL(ForStatement(Keyword,VariableName,Keyword,Array("[",Int,Int,Int,"]"),Block(BraceOpen,CreateStatement(Keyword,Ident,SetClause(Keyword,FieldAssignment(Ident,Operator,VariableName))),BraceClose)))
|
|
9
|
+
SurrealQL(ForStatement(Keyword,VariableName,Keyword,Array("[",Number(Int),Number(Int),Number(Int),"]"),Block(BraceOpen,CreateStatement(Keyword,Ident,SetClause(Keyword,FieldAssignment(Ident,Operator,VariableName))),BraceClose)))
|
|
10
10
|
|
|
11
11
|
# For loop with variable
|
|
12
12
|
|