gqlite 1.8.0 → 1.8.2
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.
- checksums.yaml +4 -4
- data/ext/Cargo.toml +8 -8
- data/ext/db-index/Cargo.toml +2 -2
- data/ext/gqlitedb/Cargo.toml +0 -2
- data/ext/gqlitedb/src/aggregators.rs +28 -0
- data/ext/gqlitedb/src/compiler/expression_analyser.rs +33 -0
- data/ext/gqlitedb/src/compiler/variables_manager.rs +111 -11
- data/ext/gqlitedb/src/compiler.rs +506 -48
- data/ext/gqlitedb/src/connection.rs +14 -2
- data/ext/gqlitedb/src/consts.rs +1 -1
- data/ext/gqlitedb/src/error.rs +31 -0
- data/ext/gqlitedb/src/interpreter/evaluators.rs +153 -331
- data/ext/gqlitedb/src/interpreter/instructions.rs +77 -0
- data/ext/gqlitedb/src/interpreter/mod.rs +1 -0
- data/ext/gqlitedb/src/interpreter/path/bfs.rs +494 -0
- data/ext/gqlitedb/src/interpreter/path/dfs.rs +267 -0
- data/ext/gqlitedb/src/interpreter/path/group.rs +418 -0
- data/ext/gqlitedb/src/interpreter/path.rs +542 -0
- data/ext/gqlitedb/src/planner.rs +231 -6
- data/ext/gqlitedb/src/query_result.rs +19 -4
- data/ext/gqlitedb/src/store/redb.rs +1 -1
- data/ext/gqlitedb/src/tests/compiler.rs +2454 -1
- data/ext/gqlitedb/src/tests/connection/postgres.rs +22 -0
- data/ext/gqlitedb/src/tests/connection/redb.rs +24 -0
- data/ext/gqlitedb/src/tests/connection/sqlite.rs +16 -0
- data/ext/gqlitedb/src/tests/connection.rs +101 -0
- data/ext/gqlitedb/src/tests/evaluators.rs +2206 -1
- data/ext/gqlitedb/src/tests/parser.rs +1225 -0
- data/ext/gqlitedb/src/tests/planner.rs +433 -2
- data/ext/gqlitedb/src/tests/store/vector_index/postgres.rs +5 -5
- data/ext/gqlitedb/src/tests/store/vector_index/sqlite.rs +3 -1
- data/ext/gqlitedb/src/tests/templates/ast.rs +294 -1
- data/ext/gqlitedb/src/tests/templates/programs.rs +318 -0
- data/ext/gqliterb/Cargo.toml +0 -1
- data/ext/gqlparser/src/oc/ast.rs +72 -3
- data/ext/gqlparser/src/oc/error.rs +18 -0
- data/ext/gqlparser/src/oc/lexer.rs +157 -2
- data/ext/gqlparser/src/oc/parser/tests.rs +735 -29
- data/ext/gqlparser/src/oc/parser.rs +1312 -182
- data/ext/gqlparser/src/oc/string.rs +172 -0
- data/ext/gqlparser/src/oc.rs +1 -0
- data/ext/graphcore/src/value/value_map.rs +2 -2
- data/ext/graphcore/src/value.rs +13 -1
- metadata +6 -2
- data/ext/gqlitedb/src/parser/gql.pest +0 -198
|
@@ -13,6 +13,8 @@ pub(crate) enum Token
|
|
|
13
13
|
And,
|
|
14
14
|
#[token("all", ignore(case))]
|
|
15
15
|
All,
|
|
16
|
+
#[token("any", ignore(case))]
|
|
17
|
+
Any,
|
|
16
18
|
#[token("as", ignore(case))]
|
|
17
19
|
As,
|
|
18
20
|
#[token("asc", ignore(case))]
|
|
@@ -22,17 +24,23 @@ pub(crate) enum Token
|
|
|
22
24
|
By,
|
|
23
25
|
#[token("call", ignore(case))]
|
|
24
26
|
Call,
|
|
27
|
+
#[token("contains", ignore(case))]
|
|
28
|
+
Contains,
|
|
29
|
+
#[token("create", ignore(case))]
|
|
30
|
+
Create,
|
|
25
31
|
#[token("desc", ignore(case))]
|
|
26
32
|
#[token("descending", ignore(case))]
|
|
27
33
|
Desc,
|
|
28
|
-
#[token("create", ignore(case))]
|
|
29
|
-
Create,
|
|
30
34
|
#[token("delete", ignore(case))]
|
|
31
35
|
Delete,
|
|
32
36
|
#[token("detach", ignore(case))]
|
|
33
37
|
Detach,
|
|
38
|
+
#[token("distinct", ignore(case))]
|
|
39
|
+
Distinct,
|
|
34
40
|
#[token("drop", ignore(case))]
|
|
35
41
|
Drop,
|
|
42
|
+
#[token("ends", ignore(case))]
|
|
43
|
+
Ends,
|
|
36
44
|
#[token("exists", ignore(case))]
|
|
37
45
|
Exists,
|
|
38
46
|
#[token("for", ignore(case))]
|
|
@@ -41,6 +49,10 @@ pub(crate) enum Token
|
|
|
41
49
|
False,
|
|
42
50
|
#[token("graph", ignore(case))]
|
|
43
51
|
Graph,
|
|
52
|
+
#[token("group", ignore(case))]
|
|
53
|
+
Group,
|
|
54
|
+
#[token("groups", ignore(case))]
|
|
55
|
+
Groups,
|
|
44
56
|
#[token("if", ignore(case))]
|
|
45
57
|
If,
|
|
46
58
|
#[token("index", ignore(case))]
|
|
@@ -65,6 +77,10 @@ pub(crate) enum Token
|
|
|
65
77
|
Search,
|
|
66
78
|
#[token("set", ignore(case))]
|
|
67
79
|
Set,
|
|
80
|
+
#[token("shortest", ignore(case))]
|
|
81
|
+
Shortest,
|
|
82
|
+
#[token("starts", ignore(case))]
|
|
83
|
+
Starts,
|
|
68
84
|
#[token("not", ignore(case))]
|
|
69
85
|
Not,
|
|
70
86
|
#[token("null", ignore(case))]
|
|
@@ -183,11 +199,13 @@ impl Token
|
|
|
183
199
|
matches!(
|
|
184
200
|
self,
|
|
185
201
|
Token::And
|
|
202
|
+
| Token::Any
|
|
186
203
|
| Token::As
|
|
187
204
|
| Token::Asc
|
|
188
205
|
| Token::By
|
|
189
206
|
| Token::Call
|
|
190
207
|
| Token::Desc
|
|
208
|
+
| Token::Distinct
|
|
191
209
|
| Token::Create
|
|
192
210
|
| Token::Delete
|
|
193
211
|
| Token::Detach
|
|
@@ -196,6 +214,8 @@ impl Token
|
|
|
196
214
|
| Token::For
|
|
197
215
|
| Token::False
|
|
198
216
|
| Token::Graph
|
|
217
|
+
| Token::Group
|
|
218
|
+
| Token::Groups
|
|
199
219
|
| Token::If
|
|
200
220
|
| Token::Index
|
|
201
221
|
| Token::In
|
|
@@ -214,6 +234,7 @@ impl Token
|
|
|
214
234
|
| Token::Score
|
|
215
235
|
| Token::Search
|
|
216
236
|
| Token::Set
|
|
237
|
+
| Token::Shortest
|
|
217
238
|
| Token::Skip
|
|
218
239
|
| Token::True
|
|
219
240
|
| Token::Union
|
|
@@ -426,4 +447,138 @@ mod tests
|
|
|
426
447
|
]
|
|
427
448
|
);
|
|
428
449
|
}
|
|
450
|
+
|
|
451
|
+
#[test]
|
|
452
|
+
fn test_oc_lexer_new_keywords()
|
|
453
|
+
{
|
|
454
|
+
// Test 'any' keyword in different cases
|
|
455
|
+
assert_eq!(
|
|
456
|
+
tokenize("any").unwrap(),
|
|
457
|
+
vec![Spanned {
|
|
458
|
+
value: Token::Any,
|
|
459
|
+
span: 0..3
|
|
460
|
+
}]
|
|
461
|
+
);
|
|
462
|
+
assert_eq!(
|
|
463
|
+
tokenize("ANY").unwrap(),
|
|
464
|
+
vec![Spanned {
|
|
465
|
+
value: Token::Any,
|
|
466
|
+
span: 0..3
|
|
467
|
+
}]
|
|
468
|
+
);
|
|
469
|
+
assert_eq!(
|
|
470
|
+
tokenize("Any").unwrap(),
|
|
471
|
+
vec![Spanned {
|
|
472
|
+
value: Token::Any,
|
|
473
|
+
span: 0..3
|
|
474
|
+
}]
|
|
475
|
+
);
|
|
476
|
+
|
|
477
|
+
// Test 'group' keyword in different cases
|
|
478
|
+
assert_eq!(
|
|
479
|
+
tokenize("group").unwrap(),
|
|
480
|
+
vec![Spanned {
|
|
481
|
+
value: Token::Group,
|
|
482
|
+
span: 0..5
|
|
483
|
+
}]
|
|
484
|
+
);
|
|
485
|
+
assert_eq!(
|
|
486
|
+
tokenize("GROUP").unwrap(),
|
|
487
|
+
vec![Spanned {
|
|
488
|
+
value: Token::Group,
|
|
489
|
+
span: 0..5
|
|
490
|
+
}]
|
|
491
|
+
);
|
|
492
|
+
assert_eq!(
|
|
493
|
+
tokenize("Group").unwrap(),
|
|
494
|
+
vec![Spanned {
|
|
495
|
+
value: Token::Group,
|
|
496
|
+
span: 0..5
|
|
497
|
+
}]
|
|
498
|
+
);
|
|
499
|
+
|
|
500
|
+
// Test 'groups' keyword in different cases
|
|
501
|
+
assert_eq!(
|
|
502
|
+
tokenize("groups").unwrap(),
|
|
503
|
+
vec![Spanned {
|
|
504
|
+
value: Token::Groups,
|
|
505
|
+
span: 0..6
|
|
506
|
+
}]
|
|
507
|
+
);
|
|
508
|
+
assert_eq!(
|
|
509
|
+
tokenize("GROUPS").unwrap(),
|
|
510
|
+
vec![Spanned {
|
|
511
|
+
value: Token::Groups,
|
|
512
|
+
span: 0..6
|
|
513
|
+
}]
|
|
514
|
+
);
|
|
515
|
+
assert_eq!(
|
|
516
|
+
tokenize("Groups").unwrap(),
|
|
517
|
+
vec![Spanned {
|
|
518
|
+
value: Token::Groups,
|
|
519
|
+
span: 0..6
|
|
520
|
+
}]
|
|
521
|
+
);
|
|
522
|
+
|
|
523
|
+
// Test 'shortest' keyword in different cases
|
|
524
|
+
assert_eq!(
|
|
525
|
+
tokenize("shortest").unwrap(),
|
|
526
|
+
vec![Spanned {
|
|
527
|
+
value: Token::Shortest,
|
|
528
|
+
span: 0..8
|
|
529
|
+
}]
|
|
530
|
+
);
|
|
531
|
+
assert_eq!(
|
|
532
|
+
tokenize("SHORTEST").unwrap(),
|
|
533
|
+
vec![Spanned {
|
|
534
|
+
value: Token::Shortest,
|
|
535
|
+
span: 0..8
|
|
536
|
+
}]
|
|
537
|
+
);
|
|
538
|
+
assert_eq!(
|
|
539
|
+
tokenize("Shortest").unwrap(),
|
|
540
|
+
vec![Spanned {
|
|
541
|
+
value: Token::Shortest,
|
|
542
|
+
span: 0..8
|
|
543
|
+
}]
|
|
544
|
+
);
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
#[test]
|
|
548
|
+
fn test_oc_lexer_reserved_keywords_compatibility()
|
|
549
|
+
{
|
|
550
|
+
// These keywords are now reserved and cannot be used as identifiers.
|
|
551
|
+
// This test demonstrates the compatibility cost: queries that previously
|
|
552
|
+
// worked with these as variable names will now fail.
|
|
553
|
+
|
|
554
|
+
// Before fix: 'any' would be tokenized as Identifier
|
|
555
|
+
// After fix: 'any' is tokenized as Token::Any (keyword)
|
|
556
|
+
let tokens = tokenize("any").unwrap();
|
|
557
|
+
assert_eq!(
|
|
558
|
+
tokens[0].value,
|
|
559
|
+
Token::Any,
|
|
560
|
+
"Expected 'any' to be reserved keyword, not identifier"
|
|
561
|
+
);
|
|
562
|
+
|
|
563
|
+
let tokens = tokenize("group").unwrap();
|
|
564
|
+
assert_eq!(
|
|
565
|
+
tokens[0].value,
|
|
566
|
+
Token::Group,
|
|
567
|
+
"Expected 'group' to be reserved keyword, not identifier"
|
|
568
|
+
);
|
|
569
|
+
|
|
570
|
+
let tokens = tokenize("groups").unwrap();
|
|
571
|
+
assert_eq!(
|
|
572
|
+
tokens[0].value,
|
|
573
|
+
Token::Groups,
|
|
574
|
+
"Expected 'groups' to be reserved keyword, not identifier"
|
|
575
|
+
);
|
|
576
|
+
|
|
577
|
+
let tokens = tokenize("shortest").unwrap();
|
|
578
|
+
assert_eq!(
|
|
579
|
+
tokens[0].value,
|
|
580
|
+
Token::Shortest,
|
|
581
|
+
"Expected 'shortest' to be reserved keyword, not identifier"
|
|
582
|
+
);
|
|
583
|
+
}
|
|
429
584
|
}
|