@surrealdb/lezer 1.0.3 → 1.0.5
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 +3 -3
- package/.turbo/turbo-run-tests.log +500 -42
- package/dist/index.cjs +68 -66
- package/dist/index.js +68 -66
- package/package.json +1 -1
- package/src/parser.js +18 -18
- package/src/parser.terms.js +234 -231
- package/src/surrealql.grammar +88 -80
- package/src/tokens.js +2 -0
- package/test/misc/comments.txt +44 -0
- package/test/misc/functions.txt +63 -0
- package/test/misc/identifiers.txt +22 -0
- package/test/misc/javascript.txt +34 -0
- package/test/misc/operators.txt +213 -0
- package/test/misc/parameters.txt +23 -0
- package/test/misc/subqueries.txt +23 -0
- package/test/statements/alter.txt +47 -0
- package/test/statements/break-continue.txt +15 -0
- package/test/statements/create.txt +103 -0
- package/test/statements/define.txt +281 -0
- package/test/statements/delete.txt +63 -0
- package/test/statements/for.txt +19 -0
- package/test/statements/if-else.txt +47 -0
- package/test/statements/info.txt +63 -0
- package/test/statements/insert.txt +63 -0
- package/test/statements/let.txt +39 -0
- package/test/statements/live.txt +47 -0
- package/test/statements/option.txt +23 -0
- package/test/statements/rebuild.txt +15 -0
- package/test/statements/relate.txt +63 -0
- package/test/statements/remove.txt +95 -0
- package/test/statements/return.txt +39 -0
- package/test/statements/select.txt +231 -0
- package/test/statements/show.txt +31 -0
- package/test/statements/sleep.txt +23 -0
- package/test/statements/throw.txt +23 -0
- package/test/statements/transactions.txt +47 -0
- package/test/statements/update.txt +87 -0
- package/test/statements/upsert.txt +55 -0
- package/test/statements/use.txt +39 -0
- package/test/test-surrealql.js +81 -9
- package/test/values/arrays.txt +47 -0
- package/test/values/casting.txt +95 -0
- package/test/values/closures.txt +39 -0
- package/test/values/durations.txt +41 -0
- package/test/values/format-strings.txt +39 -0
- package/test/values/geometries.txt +23 -0
- package/test/values/idioms.txt +228 -0
- package/test/values/literals.txt +46 -0
- package/test/values/numbers.txt +75 -0
- package/test/values/objects.txt +64 -0
- package/test/values/ranges.txt +31 -0
- package/test/values/record-ids.txt +71 -0
- package/test/values/regex.txt +31 -0
- package/test/values/sets.txt +31 -0
- package/test/values/strings.txt +69 -0
- package/test/statement.txt +0 -132
- package/test/value.txt +0 -259
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Insert with object
|
|
2
|
+
|
|
3
|
+
INSERT INTO person {name: "Tobie"}
|
|
4
|
+
|
|
5
|
+
==>
|
|
6
|
+
|
|
7
|
+
SurrealQL(InsertStatement(Keyword,Keyword,Ident,Object(BraceOpen,ObjectContent(ObjectProperty(ObjectKey(KeyName),Colon,String)),BraceClose)))
|
|
8
|
+
|
|
9
|
+
# Insert with VALUES syntax
|
|
10
|
+
|
|
11
|
+
INSERT INTO person (name, age) VALUES ("Tobie", 30)
|
|
12
|
+
|
|
13
|
+
==>
|
|
14
|
+
|
|
15
|
+
SurrealQL(InsertStatement(Keyword,Keyword,Ident,Ident,Ident,Keyword,String,Number(Int)))
|
|
16
|
+
|
|
17
|
+
# Insert with IGNORE
|
|
18
|
+
|
|
19
|
+
INSERT IGNORE INTO person {name: "Tobie"}
|
|
20
|
+
|
|
21
|
+
==>
|
|
22
|
+
|
|
23
|
+
SurrealQL(InsertStatement(Keyword,Keyword,Keyword,Ident,Object(BraceOpen,ObjectContent(ObjectProperty(ObjectKey(KeyName),Colon,String)),BraceClose)))
|
|
24
|
+
|
|
25
|
+
# Insert RELATION
|
|
26
|
+
|
|
27
|
+
INSERT RELATION INTO knows {in: person:tobie, out: person:jaime}
|
|
28
|
+
|
|
29
|
+
==>
|
|
30
|
+
|
|
31
|
+
SurrealQL(InsertStatement(Keyword,Keyword,Keyword,Ident,Object(BraceOpen,ObjectContent(ObjectProperty(ObjectKey(KeyName),Colon,RecordId(RecordTbIdent,Colon,RecordIdIdent)),ObjectProperty(ObjectKey(KeyName),Colon,RecordId(RecordTbIdent,Colon,RecordIdIdent))),BraceClose)))
|
|
32
|
+
|
|
33
|
+
# Insert bulk array
|
|
34
|
+
|
|
35
|
+
INSERT INTO person [{name: "Tobie"}, {name: "Jaime"}]
|
|
36
|
+
|
|
37
|
+
==>
|
|
38
|
+
|
|
39
|
+
SurrealQL(InsertStatement(Keyword,Keyword,Ident,BulkInsert("[",Object(BraceOpen,ObjectContent(ObjectProperty(ObjectKey(KeyName),Colon,String)),BraceClose),Object(BraceOpen,ObjectContent(ObjectProperty(ObjectKey(KeyName),Colon,String)),BraceClose),"]")))
|
|
40
|
+
|
|
41
|
+
# Insert with ON DUPLICATE KEY UPDATE
|
|
42
|
+
|
|
43
|
+
INSERT INTO person {name: "Tobie"} ON DUPLICATE KEY UPDATE age = 31
|
|
44
|
+
|
|
45
|
+
==>
|
|
46
|
+
|
|
47
|
+
SurrealQL(InsertStatement(Keyword,Keyword,Ident,Object(BraceOpen,ObjectContent(ObjectProperty(ObjectKey(KeyName),Colon,String)),BraceClose),Keyword,Keyword,Keyword,Keyword,FieldAssignment(Ident,Operator,Number(Int))))
|
|
48
|
+
|
|
49
|
+
# Insert with RETURN
|
|
50
|
+
|
|
51
|
+
INSERT INTO person {name: "Tobie"} RETURN name
|
|
52
|
+
|
|
53
|
+
==>
|
|
54
|
+
|
|
55
|
+
SurrealQL(InsertStatement(Keyword,Keyword,Ident,Object(BraceOpen,ObjectContent(ObjectProperty(ObjectKey(KeyName),Colon,String)),BraceClose),ReturnClause(Keyword,Fields(Predicate(Ident)))))
|
|
56
|
+
|
|
57
|
+
# Insert with variable
|
|
58
|
+
|
|
59
|
+
INSERT INTO person $data
|
|
60
|
+
|
|
61
|
+
==>
|
|
62
|
+
|
|
63
|
+
SurrealQL(InsertStatement(Keyword,Keyword,Ident,VariableName))
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Let with value
|
|
2
|
+
|
|
3
|
+
LET $name = "Tobie"
|
|
4
|
+
|
|
5
|
+
==>
|
|
6
|
+
|
|
7
|
+
SurrealQL(LetStatement(Keyword,ParamDefinition(VariableName),String))
|
|
8
|
+
|
|
9
|
+
# Let with number
|
|
10
|
+
|
|
11
|
+
LET $age = 30
|
|
12
|
+
|
|
13
|
+
==>
|
|
14
|
+
|
|
15
|
+
SurrealQL(LetStatement(Keyword,ParamDefinition(VariableName),Number(Int)))
|
|
16
|
+
|
|
17
|
+
# Let with subquery in parens
|
|
18
|
+
|
|
19
|
+
LET $bla = (SELECT * FROM 123)
|
|
20
|
+
|
|
21
|
+
==>
|
|
22
|
+
|
|
23
|
+
SurrealQL(LetStatement(Keyword,ParamDefinition(VariableName),SubQuery(SelectStatement(Keyword,Fields(Any),Keyword,Number(Int)))))
|
|
24
|
+
|
|
25
|
+
# Let with subquery statement
|
|
26
|
+
|
|
27
|
+
LET $bla = SELECT * FROM 123
|
|
28
|
+
|
|
29
|
+
==>
|
|
30
|
+
|
|
31
|
+
SurrealQL(LetStatement(Keyword,ParamDefinition(VariableName),SelectStatement(Keyword,Fields(Any),Keyword,Number(Int))))
|
|
32
|
+
|
|
33
|
+
# Let with typed parameter
|
|
34
|
+
|
|
35
|
+
LET $name: string = "Tobie"
|
|
36
|
+
|
|
37
|
+
==>
|
|
38
|
+
|
|
39
|
+
SurrealQL(LetStatement(Keyword,ParamDefinition(VariableName,Colon,Type(TypeName)),String))
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Live select all
|
|
2
|
+
|
|
3
|
+
LIVE SELECT * FROM person
|
|
4
|
+
|
|
5
|
+
==>
|
|
6
|
+
|
|
7
|
+
SurrealQL(LiveSelectStatement(Keyword,Keyword,Any,Keyword,Ident))
|
|
8
|
+
|
|
9
|
+
# Live select from record ID
|
|
10
|
+
|
|
11
|
+
LIVE SELECT * FROM person:tobie
|
|
12
|
+
|
|
13
|
+
==>
|
|
14
|
+
|
|
15
|
+
SurrealQL(LiveSelectStatement(Keyword,Keyword,Any,Keyword,RecordId(RecordTbIdent,Colon,RecordIdIdent)))
|
|
16
|
+
|
|
17
|
+
# Live select DIFF
|
|
18
|
+
|
|
19
|
+
LIVE SELECT DIFF FROM person
|
|
20
|
+
|
|
21
|
+
==>
|
|
22
|
+
|
|
23
|
+
SurrealQL(LiveSelectStatement(Keyword,Keyword,Literal,Keyword,Ident))
|
|
24
|
+
|
|
25
|
+
# Live select specific fields
|
|
26
|
+
|
|
27
|
+
LIVE SELECT name, age FROM person
|
|
28
|
+
|
|
29
|
+
==>
|
|
30
|
+
|
|
31
|
+
SurrealQL(LiveSelectStatement(Keyword,Keyword,Predicate(Ident),Predicate(Ident),Keyword,Ident))
|
|
32
|
+
|
|
33
|
+
# Live select with WHERE
|
|
34
|
+
|
|
35
|
+
LIVE SELECT * FROM person WHERE age > 18
|
|
36
|
+
|
|
37
|
+
==>
|
|
38
|
+
|
|
39
|
+
SurrealQL(LiveSelectStatement(Keyword,Keyword,Any,Keyword,Ident,WhereClause(Keyword,BinaryExpression(Ident,Operator,Number(Int)))))
|
|
40
|
+
|
|
41
|
+
# Kill statement
|
|
42
|
+
|
|
43
|
+
KILL "some-uuid-here"
|
|
44
|
+
|
|
45
|
+
==>
|
|
46
|
+
|
|
47
|
+
SurrealQL(KillStatement(Keyword,String))
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Option without value
|
|
2
|
+
|
|
3
|
+
OPTION IMPORT
|
|
4
|
+
|
|
5
|
+
==>
|
|
6
|
+
|
|
7
|
+
SurrealQL(OptionStatement(Keyword,Ident))
|
|
8
|
+
|
|
9
|
+
# Option with true
|
|
10
|
+
|
|
11
|
+
OPTION IMPORT = true
|
|
12
|
+
|
|
13
|
+
==>
|
|
14
|
+
|
|
15
|
+
SurrealQL(OptionStatement(Keyword,Ident,Bool))
|
|
16
|
+
|
|
17
|
+
# Option with false
|
|
18
|
+
|
|
19
|
+
OPTION IMPORT = false
|
|
20
|
+
|
|
21
|
+
==>
|
|
22
|
+
|
|
23
|
+
SurrealQL(OptionStatement(Keyword,Ident,Bool))
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Rebuild index
|
|
2
|
+
|
|
3
|
+
REBUILD INDEX idx_email ON TABLE person
|
|
4
|
+
|
|
5
|
+
==>
|
|
6
|
+
|
|
7
|
+
SurrealQL(RebuildStatement(Keyword,Keyword,Ident,OnTableClause(Keyword,Keyword,Ident)))
|
|
8
|
+
|
|
9
|
+
# Rebuild index if exists
|
|
10
|
+
|
|
11
|
+
REBUILD INDEX IF EXISTS idx_email ON TABLE person
|
|
12
|
+
|
|
13
|
+
==>
|
|
14
|
+
|
|
15
|
+
SurrealQL(RebuildStatement(Keyword,Keyword,IfExistsClause(Keyword,Keyword),Ident,OnTableClause(Keyword,Keyword,Ident)))
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Simple relate
|
|
2
|
+
|
|
3
|
+
RELATE person:tobie->knows->person:jaime
|
|
4
|
+
|
|
5
|
+
==>
|
|
6
|
+
|
|
7
|
+
SurrealQL(RelateStatement(Keyword,RecordId(RecordTbIdent,Colon,RecordIdIdent),LookupRight,Ident,LookupRight,RecordId(RecordTbIdent,Colon,RecordIdIdent)))
|
|
8
|
+
|
|
9
|
+
# Relate ONLY
|
|
10
|
+
|
|
11
|
+
RELATE ONLY person:tobie->knows->person:jaime
|
|
12
|
+
|
|
13
|
+
==>
|
|
14
|
+
|
|
15
|
+
SurrealQL(RelateStatement(Keyword,Keyword,RecordId(RecordTbIdent,Colon,RecordIdIdent),LookupRight,Ident,LookupRight,RecordId(RecordTbIdent,Colon,RecordIdIdent)))
|
|
16
|
+
|
|
17
|
+
# Relate with SET
|
|
18
|
+
|
|
19
|
+
RELATE person:tobie->knows->person:jaime SET since = "2024-01-01"
|
|
20
|
+
|
|
21
|
+
==>
|
|
22
|
+
|
|
23
|
+
SurrealQL(RelateStatement(Keyword,RecordId(RecordTbIdent,Colon,RecordIdIdent),LookupRight,Ident,LookupRight,RecordId(RecordTbIdent,Colon,RecordIdIdent),SetClause(Keyword,FieldAssignment(Ident,Operator,String))))
|
|
24
|
+
|
|
25
|
+
# Relate with CONTENT
|
|
26
|
+
|
|
27
|
+
RELATE person:tobie->knows->person:jaime CONTENT {since: "2024-01-01"}
|
|
28
|
+
|
|
29
|
+
==>
|
|
30
|
+
|
|
31
|
+
SurrealQL(RelateStatement(Keyword,RecordId(RecordTbIdent,Colon,RecordIdIdent),LookupRight,Ident,LookupRight,RecordId(RecordTbIdent,Colon,RecordIdIdent),ContentClause(Keyword,Object(BraceOpen,ObjectContent(ObjectProperty(ObjectKey(KeyName),Colon,String)),BraceClose))))
|
|
32
|
+
|
|
33
|
+
# Relate with RETURN
|
|
34
|
+
|
|
35
|
+
RELATE person:tobie->knows->person:jaime RETURN AFTER
|
|
36
|
+
|
|
37
|
+
==>
|
|
38
|
+
|
|
39
|
+
SurrealQL(RelateStatement(Keyword,RecordId(RecordTbIdent,Colon,RecordIdIdent),LookupRight,Ident,LookupRight,RecordId(RecordTbIdent,Colon,RecordIdIdent),ReturnClause(Keyword,Literal)))
|
|
40
|
+
|
|
41
|
+
# Relate with ident subjects
|
|
42
|
+
|
|
43
|
+
RELATE person->knows->person
|
|
44
|
+
|
|
45
|
+
==>
|
|
46
|
+
|
|
47
|
+
SurrealQL(RelateStatement(Keyword,Ident,LookupRight,Ident,LookupRight,Ident))
|
|
48
|
+
|
|
49
|
+
# Relate with variable subject
|
|
50
|
+
|
|
51
|
+
RELATE $from->knows->$to
|
|
52
|
+
|
|
53
|
+
==>
|
|
54
|
+
|
|
55
|
+
SurrealQL(RelateStatement(Keyword,VariableName,LookupRight,Ident,LookupRight,VariableName))
|
|
56
|
+
|
|
57
|
+
# Relate with array subject
|
|
58
|
+
|
|
59
|
+
RELATE [person:tobie]->knows->person:jaime
|
|
60
|
+
|
|
61
|
+
==>
|
|
62
|
+
|
|
63
|
+
SurrealQL(RelateStatement(Keyword,Array("[",RecordId(RecordTbIdent,Colon,RecordIdIdent),"]"),LookupRight,Ident,LookupRight,RecordId(RecordTbIdent,Colon,RecordIdIdent)))
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Remove namespace
|
|
2
|
+
|
|
3
|
+
REMOVE NAMESPACE test
|
|
4
|
+
|
|
5
|
+
==>
|
|
6
|
+
|
|
7
|
+
SurrealQL(RemoveStatement(Keyword,Keyword,Ident))
|
|
8
|
+
|
|
9
|
+
# Remove database
|
|
10
|
+
|
|
11
|
+
REMOVE DATABASE test
|
|
12
|
+
|
|
13
|
+
==>
|
|
14
|
+
|
|
15
|
+
SurrealQL(RemoveStatement(Keyword,Keyword,Ident))
|
|
16
|
+
|
|
17
|
+
# Remove user
|
|
18
|
+
|
|
19
|
+
REMOVE USER tobie ON ROOT
|
|
20
|
+
|
|
21
|
+
==>
|
|
22
|
+
|
|
23
|
+
SurrealQL(RemoveStatement(Keyword,Keyword,Ident,Keyword,Keyword))
|
|
24
|
+
|
|
25
|
+
# Remove token
|
|
26
|
+
|
|
27
|
+
REMOVE TOKEN mytoken ON NAMESPACE
|
|
28
|
+
|
|
29
|
+
==>
|
|
30
|
+
|
|
31
|
+
SurrealQL(RemoveStatement(Keyword,Keyword,Ident,Keyword,Keyword))
|
|
32
|
+
|
|
33
|
+
# Remove event
|
|
34
|
+
|
|
35
|
+
REMOVE EVENT myevent ON TABLE person
|
|
36
|
+
|
|
37
|
+
==>
|
|
38
|
+
|
|
39
|
+
SurrealQL(RemoveStatement(Keyword,Keyword,Ident,OnTableClause(Keyword,Keyword,Ident)))
|
|
40
|
+
|
|
41
|
+
# Remove field
|
|
42
|
+
|
|
43
|
+
REMOVE FIELD name ON TABLE person
|
|
44
|
+
|
|
45
|
+
==>
|
|
46
|
+
|
|
47
|
+
SurrealQL(RemoveStatement(Keyword,Keyword,Ident,OnTableClause(Keyword,Keyword,Ident)))
|
|
48
|
+
|
|
49
|
+
# Remove index
|
|
50
|
+
|
|
51
|
+
REMOVE INDEX idx_email ON TABLE person
|
|
52
|
+
|
|
53
|
+
==>
|
|
54
|
+
|
|
55
|
+
SurrealQL(RemoveStatement(Keyword,Keyword,Ident,OnTableClause(Keyword,Keyword,Ident)))
|
|
56
|
+
|
|
57
|
+
# Remove analyzer
|
|
58
|
+
|
|
59
|
+
REMOVE ANALYZER my_analyzer
|
|
60
|
+
|
|
61
|
+
==>
|
|
62
|
+
|
|
63
|
+
SurrealQL(RemoveStatement(Keyword,Keyword,Ident))
|
|
64
|
+
|
|
65
|
+
# Remove function
|
|
66
|
+
|
|
67
|
+
REMOVE FUNCTION fn::update_author
|
|
68
|
+
|
|
69
|
+
==>
|
|
70
|
+
|
|
71
|
+
SurrealQL(RemoveStatement(Keyword,Keyword,FunctionName))
|
|
72
|
+
|
|
73
|
+
# Remove param
|
|
74
|
+
|
|
75
|
+
REMOVE PARAM $endpointBase
|
|
76
|
+
|
|
77
|
+
==>
|
|
78
|
+
|
|
79
|
+
SurrealQL(RemoveStatement(Keyword,Keyword,VariableName))
|
|
80
|
+
|
|
81
|
+
# Remove scope
|
|
82
|
+
|
|
83
|
+
REMOVE SCOPE account
|
|
84
|
+
|
|
85
|
+
==>
|
|
86
|
+
|
|
87
|
+
SurrealQL(RemoveStatement(Keyword,Keyword,Ident))
|
|
88
|
+
|
|
89
|
+
# Remove bucket
|
|
90
|
+
|
|
91
|
+
REMOVE BUCKET mybucket
|
|
92
|
+
|
|
93
|
+
==>
|
|
94
|
+
|
|
95
|
+
SurrealQL(RemoveStatement(Keyword,Keyword,Ident))
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Return value
|
|
2
|
+
|
|
3
|
+
RETURN 42
|
|
4
|
+
|
|
5
|
+
==>
|
|
6
|
+
|
|
7
|
+
SurrealQL(ReturnStatement(Keyword,Number(Int)))
|
|
8
|
+
|
|
9
|
+
# Return string
|
|
10
|
+
|
|
11
|
+
RETURN "hello"
|
|
12
|
+
|
|
13
|
+
==>
|
|
14
|
+
|
|
15
|
+
SurrealQL(ReturnStatement(Keyword,String))
|
|
16
|
+
|
|
17
|
+
# Return expression
|
|
18
|
+
|
|
19
|
+
RETURN 1 + 2
|
|
20
|
+
|
|
21
|
+
==>
|
|
22
|
+
|
|
23
|
+
SurrealQL(ReturnStatement(Keyword,BinaryExpression(Number(Int),Operator,Number(Int))))
|
|
24
|
+
|
|
25
|
+
# Return variable
|
|
26
|
+
|
|
27
|
+
RETURN $result
|
|
28
|
+
|
|
29
|
+
==>
|
|
30
|
+
|
|
31
|
+
SurrealQL(ReturnStatement(Keyword,VariableName))
|
|
32
|
+
|
|
33
|
+
# Return function call
|
|
34
|
+
|
|
35
|
+
RETURN fn::greet("Tobie")
|
|
36
|
+
|
|
37
|
+
==>
|
|
38
|
+
|
|
39
|
+
SurrealQL(ReturnStatement(Keyword,FunctionCall(FunctionName,ArgumentList(String))))
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
# Simple select all
|
|
2
|
+
|
|
3
|
+
SELECT * FROM test
|
|
4
|
+
|
|
5
|
+
==>
|
|
6
|
+
|
|
7
|
+
SurrealQL(SelectStatement(Keyword,Fields(Any),Keyword,Ident))
|
|
8
|
+
|
|
9
|
+
# Select specific fields
|
|
10
|
+
|
|
11
|
+
SELECT name, age FROM person
|
|
12
|
+
|
|
13
|
+
==>
|
|
14
|
+
|
|
15
|
+
SurrealQL(SelectStatement(Keyword,Fields(Predicate(Ident),Predicate(Ident)),Keyword,Ident))
|
|
16
|
+
|
|
17
|
+
# Select with alias
|
|
18
|
+
|
|
19
|
+
SELECT name AS n FROM person
|
|
20
|
+
|
|
21
|
+
==>
|
|
22
|
+
|
|
23
|
+
SurrealQL(SelectStatement(Keyword,Fields(Predicate(Ident,Keyword,Ident)),Keyword,Ident))
|
|
24
|
+
|
|
25
|
+
# Select VALUE
|
|
26
|
+
|
|
27
|
+
SELECT VALUE name FROM person
|
|
28
|
+
|
|
29
|
+
==>
|
|
30
|
+
|
|
31
|
+
SurrealQL(SelectStatement(Keyword,Fields(Keyword,Predicate(Ident)),Keyword,Ident))
|
|
32
|
+
|
|
33
|
+
# Select ONLY
|
|
34
|
+
|
|
35
|
+
SELECT * FROM ONLY person:tobie
|
|
36
|
+
|
|
37
|
+
==>
|
|
38
|
+
|
|
39
|
+
SurrealQL(SelectStatement(Keyword,Fields(Any),Keyword,Keyword,RecordId(RecordTbIdent,Colon,RecordIdIdent)))
|
|
40
|
+
|
|
41
|
+
# Select with WHERE
|
|
42
|
+
|
|
43
|
+
SELECT * FROM person WHERE age > 18
|
|
44
|
+
|
|
45
|
+
==>
|
|
46
|
+
|
|
47
|
+
SurrealQL(SelectStatement(Keyword,Fields(Any),Keyword,Ident,WhereClause(Keyword,BinaryExpression(Ident,Operator,Number(Int)))))
|
|
48
|
+
|
|
49
|
+
# Select with ORDER BY
|
|
50
|
+
|
|
51
|
+
SELECT * FROM person ORDER BY name ASC
|
|
52
|
+
|
|
53
|
+
==>
|
|
54
|
+
|
|
55
|
+
SurrealQL(SelectStatement(Keyword,Fields(Any),Keyword,Ident,OrderClause(Keyword,Keyword,Order(Idiom(Ident),Keyword))))
|
|
56
|
+
|
|
57
|
+
# Select with ORDER BY DESC
|
|
58
|
+
|
|
59
|
+
SELECT * FROM person ORDER BY age DESC
|
|
60
|
+
|
|
61
|
+
==>
|
|
62
|
+
|
|
63
|
+
SurrealQL(SelectStatement(Keyword,Fields(Any),Keyword,Ident,OrderClause(Keyword,Keyword,Order(Idiom(Ident),Keyword))))
|
|
64
|
+
|
|
65
|
+
# Select with GROUP BY
|
|
66
|
+
|
|
67
|
+
SELECT count() FROM person GROUP BY age
|
|
68
|
+
|
|
69
|
+
==>
|
|
70
|
+
|
|
71
|
+
SurrealQL(SelectStatement(Keyword,Fields(Predicate(FunctionCall(FunctionName,ArgumentList))),Keyword,Ident,GroupClause(Keyword,Keyword,Idiom(Ident))))
|
|
72
|
+
|
|
73
|
+
# Select with GROUP ALL
|
|
74
|
+
|
|
75
|
+
SELECT count() FROM person GROUP ALL
|
|
76
|
+
|
|
77
|
+
==>
|
|
78
|
+
|
|
79
|
+
SurrealQL(SelectStatement(Keyword,Fields(Predicate(FunctionCall(FunctionName,ArgumentList))),Keyword,Ident,GroupClause(Keyword,Keyword)))
|
|
80
|
+
|
|
81
|
+
# Select with LIMIT
|
|
82
|
+
|
|
83
|
+
SELECT * FROM person LIMIT 10
|
|
84
|
+
|
|
85
|
+
==>
|
|
86
|
+
|
|
87
|
+
SurrealQL(SelectStatement(Keyword,Fields(Any),Keyword,Ident,LimitStartComboClause(LimitClause(Keyword,Number(Int)))))
|
|
88
|
+
|
|
89
|
+
# Select with LIMIT BY
|
|
90
|
+
|
|
91
|
+
SELECT * FROM person LIMIT BY 10
|
|
92
|
+
|
|
93
|
+
==>
|
|
94
|
+
|
|
95
|
+
SurrealQL(SelectStatement(Keyword,Fields(Any),Keyword,Ident,LimitStartComboClause(LimitClause(Keyword,Keyword,Number(Int)))))
|
|
96
|
+
|
|
97
|
+
# Select with START
|
|
98
|
+
|
|
99
|
+
SELECT * FROM person START 5
|
|
100
|
+
|
|
101
|
+
==>
|
|
102
|
+
|
|
103
|
+
SurrealQL(SelectStatement(Keyword,Fields(Any),Keyword,Ident,LimitStartComboClause(StartClause(Keyword,Number(Int)))))
|
|
104
|
+
|
|
105
|
+
# Select with START AT
|
|
106
|
+
|
|
107
|
+
SELECT * FROM person START AT 5
|
|
108
|
+
|
|
109
|
+
==>
|
|
110
|
+
|
|
111
|
+
SurrealQL(SelectStatement(Keyword,Fields(Any),Keyword,Ident,LimitStartComboClause(StartClause(Keyword,Keyword,Number(Int)))))
|
|
112
|
+
|
|
113
|
+
# Select with LIMIT and START
|
|
114
|
+
|
|
115
|
+
SELECT * FROM person LIMIT 10 START 5
|
|
116
|
+
|
|
117
|
+
==>
|
|
118
|
+
|
|
119
|
+
SurrealQL(SelectStatement(Keyword,Fields(Any),Keyword,Ident,LimitStartComboClause(LimitClause(Keyword,Number(Int)),StartClause(Keyword,Number(Int)))))
|
|
120
|
+
|
|
121
|
+
# Select with FETCH
|
|
122
|
+
|
|
123
|
+
SELECT * FROM person FETCH posts
|
|
124
|
+
|
|
125
|
+
==>
|
|
126
|
+
|
|
127
|
+
SurrealQL(SelectStatement(Keyword,Fields(Any),Keyword,Ident,FetchClause(Keyword,Idiom(Ident))))
|
|
128
|
+
|
|
129
|
+
# Select with SPLIT
|
|
130
|
+
|
|
131
|
+
SELECT * FROM person SPLIT emails
|
|
132
|
+
|
|
133
|
+
==>
|
|
134
|
+
|
|
135
|
+
SurrealQL(SelectStatement(Keyword,Fields(Any),Keyword,Ident,SplitClause(Keyword,Idiom(Ident))))
|
|
136
|
+
|
|
137
|
+
# Select with OMIT
|
|
138
|
+
|
|
139
|
+
SELECT * OMIT password FROM person
|
|
140
|
+
|
|
141
|
+
==>
|
|
142
|
+
|
|
143
|
+
SurrealQL(SelectStatement(Keyword,Fields(Any),OmitClause(Keyword,Predicate(Ident)),Keyword,Ident))
|
|
144
|
+
|
|
145
|
+
# Select with WITH INDEX
|
|
146
|
+
|
|
147
|
+
SELECT * FROM person WITH INDEX idx_name
|
|
148
|
+
|
|
149
|
+
==>
|
|
150
|
+
|
|
151
|
+
SurrealQL(SelectStatement(Keyword,Fields(Any),Keyword,Ident,WithClause(Keyword,Keyword,Ident)))
|
|
152
|
+
|
|
153
|
+
# Select with WITH NOINDEX
|
|
154
|
+
|
|
155
|
+
SELECT * FROM person WITH NOINDEX
|
|
156
|
+
|
|
157
|
+
==>
|
|
158
|
+
|
|
159
|
+
SurrealQL(SelectStatement(Keyword,Fields(Any),Keyword,Ident,WithClause(Keyword,Keyword)))
|
|
160
|
+
|
|
161
|
+
# Select with EXPLAIN
|
|
162
|
+
|
|
163
|
+
SELECT * FROM person EXPLAIN
|
|
164
|
+
|
|
165
|
+
==>
|
|
166
|
+
|
|
167
|
+
SurrealQL(SelectStatement(Keyword,Fields(Any),Keyword,Ident,ExplainClause(Keyword)))
|
|
168
|
+
|
|
169
|
+
# Select with EXPLAIN FULL
|
|
170
|
+
|
|
171
|
+
SELECT * FROM person EXPLAIN FULL
|
|
172
|
+
|
|
173
|
+
==>
|
|
174
|
+
|
|
175
|
+
SurrealQL(SelectStatement(Keyword,Fields(Any),Keyword,Ident,ExplainClause(Keyword,Literal)))
|
|
176
|
+
|
|
177
|
+
# Select with PARALLEL
|
|
178
|
+
|
|
179
|
+
SELECT * FROM person PARALLEL
|
|
180
|
+
|
|
181
|
+
==>
|
|
182
|
+
|
|
183
|
+
SurrealQL(SelectStatement(Keyword,Fields(Any),Keyword,Ident,ParallelClause(Keyword)))
|
|
184
|
+
|
|
185
|
+
# Select with TEMPFILES
|
|
186
|
+
|
|
187
|
+
SELECT * FROM person TEMPFILES
|
|
188
|
+
|
|
189
|
+
==>
|
|
190
|
+
|
|
191
|
+
SurrealQL(SelectStatement(Keyword,Fields(Any),Keyword,Ident,TempfilesClause(Keyword)))
|
|
192
|
+
|
|
193
|
+
# Select with TIMEOUT
|
|
194
|
+
|
|
195
|
+
SELECT * FROM person TIMEOUT 5s
|
|
196
|
+
|
|
197
|
+
==>
|
|
198
|
+
|
|
199
|
+
SurrealQL(SelectStatement(Keyword,Fields(Any),Keyword,Ident,TimeoutClause(Keyword,Duration(DurationPart))))
|
|
200
|
+
|
|
201
|
+
# Select with VERSION
|
|
202
|
+
|
|
203
|
+
SELECT * FROM person VERSION d'2024-10-10T14:37:08.444Z'
|
|
204
|
+
|
|
205
|
+
==>
|
|
206
|
+
|
|
207
|
+
SurrealQL(SelectStatement(Keyword,Fields(Any),Keyword,Ident,VersionClause(Keyword,String)))
|
|
208
|
+
|
|
209
|
+
# Select with multiple clauses
|
|
210
|
+
|
|
211
|
+
SELECT * FROM person WHERE age > 18 ORDER BY name LIMIT 10
|
|
212
|
+
|
|
213
|
+
==>
|
|
214
|
+
|
|
215
|
+
SurrealQL(SelectStatement(Keyword,Fields(Any),Keyword,Ident,WhereClause(Keyword,BinaryExpression(Ident,Operator,Number(Int))),OrderClause(Keyword,Keyword,Order(Idiom(Ident))),LimitStartComboClause(LimitClause(Keyword,Number(Int)))))
|
|
216
|
+
|
|
217
|
+
# Select from multiple targets
|
|
218
|
+
|
|
219
|
+
SELECT * FROM person, animal
|
|
220
|
+
|
|
221
|
+
==>
|
|
222
|
+
|
|
223
|
+
SurrealQL(SelectStatement(Keyword,Fields(Any),Keyword,Ident,Ident))
|
|
224
|
+
|
|
225
|
+
# Select from subquery
|
|
226
|
+
|
|
227
|
+
SELECT * FROM (SELECT * FROM person)
|
|
228
|
+
|
|
229
|
+
==>
|
|
230
|
+
|
|
231
|
+
SurrealQL(SelectStatement(Keyword,Fields(Any),Keyword,SubQuery(SelectStatement(Keyword,Fields(Any),Keyword,Ident))))
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Show changes for table
|
|
2
|
+
|
|
3
|
+
SHOW CHANGES FOR TABLE person
|
|
4
|
+
|
|
5
|
+
==>
|
|
6
|
+
|
|
7
|
+
SurrealQL(ShowStatement(Keyword,Keyword,Keyword,Keyword,Ident))
|
|
8
|
+
|
|
9
|
+
# Show changes with since
|
|
10
|
+
|
|
11
|
+
SHOW CHANGES FOR TABLE person SINCE "2024-01-01T00:00:00Z"
|
|
12
|
+
|
|
13
|
+
==>
|
|
14
|
+
|
|
15
|
+
SurrealQL(ShowStatement(Keyword,Keyword,Keyword,Keyword,Ident,Keyword,String))
|
|
16
|
+
|
|
17
|
+
# Show changes with limit
|
|
18
|
+
|
|
19
|
+
SHOW CHANGES FOR TABLE person LIMIT 10
|
|
20
|
+
|
|
21
|
+
==>
|
|
22
|
+
|
|
23
|
+
SurrealQL(ShowStatement(Keyword,Keyword,Keyword,Keyword,Ident,Keyword,Number(Int)))
|
|
24
|
+
|
|
25
|
+
# Show changes with since and limit
|
|
26
|
+
|
|
27
|
+
SHOW CHANGES FOR TABLE person SINCE "2024-01-01T00:00:00Z" LIMIT 10
|
|
28
|
+
|
|
29
|
+
==>
|
|
30
|
+
|
|
31
|
+
SurrealQL(ShowStatement(Keyword,Keyword,Keyword,Keyword,Ident,Keyword,String,Keyword,Number(Int)))
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Sleep with seconds
|
|
2
|
+
|
|
3
|
+
SLEEP 1s
|
|
4
|
+
|
|
5
|
+
==>
|
|
6
|
+
|
|
7
|
+
SurrealQL(SleepStatement(Keyword,Duration(DurationPart)))
|
|
8
|
+
|
|
9
|
+
# Sleep with milliseconds
|
|
10
|
+
|
|
11
|
+
SLEEP 100ms
|
|
12
|
+
|
|
13
|
+
==>
|
|
14
|
+
|
|
15
|
+
SurrealQL(SleepStatement(Keyword,Duration(DurationPart)))
|
|
16
|
+
|
|
17
|
+
# Sleep with multi-part duration
|
|
18
|
+
|
|
19
|
+
SLEEP 1m30s
|
|
20
|
+
|
|
21
|
+
==>
|
|
22
|
+
|
|
23
|
+
SurrealQL(SleepStatement(Keyword,Duration(DurationPart,DurationPart)))
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Throw string
|
|
2
|
+
|
|
3
|
+
THROW "An error occurred"
|
|
4
|
+
|
|
5
|
+
==>
|
|
6
|
+
|
|
7
|
+
SurrealQL(ThrowStatement(Keyword,String))
|
|
8
|
+
|
|
9
|
+
# Throw variable
|
|
10
|
+
|
|
11
|
+
THROW $error
|
|
12
|
+
|
|
13
|
+
==>
|
|
14
|
+
|
|
15
|
+
SurrealQL(ThrowStatement(Keyword,VariableName))
|
|
16
|
+
|
|
17
|
+
# Throw expression
|
|
18
|
+
|
|
19
|
+
THROW "Error: " + $msg
|
|
20
|
+
|
|
21
|
+
==>
|
|
22
|
+
|
|
23
|
+
SurrealQL(ThrowStatement(Keyword,BinaryExpression(String,Operator,VariableName)))
|