gqlite 1.2.2 → 1.3.0

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.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/ext/Cargo.toml +20 -0
  3. data/ext/gqlitedb/Cargo.toml +77 -0
  4. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/benches/common/pokec.rs +30 -20
  5. data/ext/gqlitedb/gqlite_bench_data/README.MD +6 -0
  6. data/ext/gqlitedb/gqlite_bench_data/scripts/generate_smaller_pokec.rb +85 -0
  7. data/ext/gqlitedb/gqlite_bench_data/scripts/to_efficient_pokec.rb +34 -0
  8. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/release.toml +2 -2
  9. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/aggregators/arithmetic.rs +1 -0
  10. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/aggregators/stats.rs +27 -49
  11. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/aggregators.rs +7 -7
  12. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/capi.rs +34 -10
  13. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/compiler/expression_analyser.rs +10 -4
  14. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/compiler/variables_manager.rs +36 -39
  15. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/compiler.rs +46 -41
  16. data/ext/gqlitedb/src/connection.rs +300 -0
  17. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/error.rs +113 -50
  18. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions/containers.rs +21 -26
  19. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions/edge.rs +3 -3
  20. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions/math.rs +3 -3
  21. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions/node.rs +2 -2
  22. data/ext/gqlitedb/src/functions/path.rs +75 -0
  23. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions/scalar.rs +3 -3
  24. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions/string.rs +1 -1
  25. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions/value.rs +7 -7
  26. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions.rs +29 -31
  27. data/ext/gqlitedb/src/graph.rs +11 -0
  28. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/interpreter/evaluators.rs +178 -224
  29. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/interpreter/instructions.rs +8 -2
  30. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/lib.rs +9 -5
  31. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/parser/ast.rs +54 -76
  32. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/parser/gql.pest +9 -4
  33. data/ext/{gqliterb/vendor/gqlitedb/src/parser/parser.rs → gqlitedb/src/parser/parser_impl.rs} +86 -34
  34. data/ext/gqlitedb/src/parser.rs +4 -0
  35. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/prelude.rs +3 -2
  36. data/ext/gqlitedb/src/query_result.rs +88 -0
  37. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/store/redb.rs +260 -170
  38. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/store/sqlite.rs +157 -142
  39. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/store.rs +30 -23
  40. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/evaluators.rs +41 -85
  41. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/store/redb.rs +12 -5
  42. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/store/sqlite.rs +12 -5
  43. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/store.rs +106 -114
  44. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/templates/ast.rs +29 -29
  45. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/templates/programs.rs +4 -4
  46. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/value/compare.rs +13 -20
  47. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/value/contains.rs +2 -2
  48. data/ext/gqlitedb/src/value.rs +225 -0
  49. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/value_table.rs +22 -18
  50. data/ext/gqliterb/Cargo.toml +12 -34
  51. data/ext/gqliterb/src/lib.rs +67 -39
  52. data/ext/graphcore/Cargo.toml +19 -0
  53. data/ext/graphcore/README.MD +4 -0
  54. data/ext/graphcore/release.toml +1 -0
  55. data/ext/graphcore/src/error.rs +28 -0
  56. data/ext/{gqliterb/vendor/gqlitedb → graphcore}/src/graph.rs +146 -35
  57. data/ext/graphcore/src/lib.rs +16 -0
  58. data/ext/graphcore/src/prelude.rs +4 -0
  59. data/ext/{gqliterb/vendor/gqlitedb → graphcore}/src/serialize_with.rs +2 -2
  60. data/ext/graphcore/src/table.rs +272 -0
  61. data/ext/{gqliterb/vendor/gqlitedb → graphcore}/src/value/value_map.rs +44 -49
  62. data/ext/graphcore/src/value.rs +413 -0
  63. metadata +94 -83
  64. data/ext/gqliterb/.cargo/config.toml +0 -2
  65. data/ext/gqliterb/Cargo.lock +0 -1109
  66. data/ext/gqliterb/vendor/gqlitedb/Cargo.lock +0 -2060
  67. data/ext/gqliterb/vendor/gqlitedb/Cargo.toml +0 -132
  68. data/ext/gqliterb/vendor/gqlitedb/src/connection.rs +0 -208
  69. data/ext/gqliterb/vendor/gqlitedb/src/functions/path.rs +0 -48
  70. data/ext/gqliterb/vendor/gqlitedb/src/parser.rs +0 -4
  71. data/ext/gqliterb/vendor/gqlitedb/src/value.rs +0 -559
  72. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/askama.toml +0 -0
  73. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/benches/common/mod.rs +0 -0
  74. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/benches/pokec_divan.rs +0 -0
  75. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/benches/pokec_iai.rs +0 -0
  76. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/aggregators/containers.rs +0 -0
  77. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/aggregators/count.rs +0 -0
  78. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/consts.rs +0 -0
  79. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/interpreter/mod.rs +0 -0
  80. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/store/pgql.rs +0 -0
  81. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/compiler.rs +0 -0
  82. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/parser.rs +0 -0
  83. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/templates.rs +0 -0
  84. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests.rs +0 -0
  85. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/utils.rs +0 -0
  86. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/call_stats.sql +0 -0
  87. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/edge_count_for_node.sql +0 -0
  88. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/edge_create.sql +0 -0
  89. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/edge_delete.sql +0 -0
  90. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/edge_delete_by_nodes.sql +0 -0
  91. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/edge_select.sql +0 -0
  92. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/edge_update.sql +0 -0
  93. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/graph_create.sql +0 -0
  94. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/graph_delete.sql +0 -0
  95. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/metadata_create_table.sql +0 -0
  96. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/metadata_get.sql +0 -0
  97. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/metadata_set.sql +0 -0
  98. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/node_create.sql +0 -0
  99. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/node_delete.sql +0 -0
  100. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/node_select.sql +0 -0
  101. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/node_update.sql +0 -0
  102. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/table_exists.sql +0 -0
  103. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/upgrade_from_1_01.sql +0 -0
  104. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/upgrade_graph_from_1_01.sql +0 -0
@@ -1,6 +1,7 @@
1
1
  use crate::{prelude::*, value_table::ColId};
2
2
 
3
3
  #[derive(Debug)]
4
+ #[allow(clippy::large_enum_variant)]
4
5
  pub(crate) enum Instruction
5
6
  {
6
7
  CreateNodeLiteral
@@ -58,7 +59,6 @@ pub(crate) enum Instruction
58
59
  Rot3, // If a is the top of the stack, then a b c -> b c a
59
60
  InverseRot3, // If a is the top of the stack, then a b c -> c a b
60
61
  Swap,
61
- Drop,
62
62
  AndBinaryOperator,
63
63
  OrBinaryOperator,
64
64
  XorBinaryOperator,
@@ -78,6 +78,7 @@ pub(crate) enum Instruction
78
78
  MultiplicationBinaryOperator,
79
79
  DivisionBinaryOperator,
80
80
  ModuloBinaryOperator,
81
+ ExponentBinaryOperator,
81
82
  }
82
83
 
83
84
  pub(crate) type Instructions = Vec<Instruction>;
@@ -208,6 +209,10 @@ pub(crate) enum Block
208
209
  {
209
210
  name: String
210
211
  },
212
+ DropGraph
213
+ {
214
+ name: String, if_exists: bool
215
+ },
211
216
  UseGraph
212
217
  {
213
218
  name: String
@@ -217,7 +222,7 @@ pub(crate) enum Block
217
222
  actions: Vec<CreateAction>,
218
223
  variables_size: VariablesSizes,
219
224
  },
220
- BlockMatch
225
+ Match
221
226
  {
222
227
  blocks: Vec<BlockMatch>,
223
228
  filter: Instructions,
@@ -233,6 +238,7 @@ pub(crate) enum Block
233
238
  },
234
239
  Call
235
240
  {
241
+ #[allow(dead_code)]
236
242
  arguments: Instructions,
237
243
  name: String,
238
244
  },
@@ -7,8 +7,9 @@
7
7
  //! for an example of use.
8
8
 
9
9
  #![warn(missing_docs)]
10
- #![allow(dead_code)]
11
10
  #![deny(warnings)]
11
+ #![allow(clippy::result_large_err)]
12
+ #![allow(clippy::unnecessary_lazy_evaluations)]
12
13
 
13
14
  mod aggregators;
14
15
  #[cfg(feature = "capi")]
@@ -22,7 +23,7 @@ mod graph;
22
23
  mod interpreter;
23
24
  mod parser;
24
25
  mod prelude;
25
- mod serialize_with;
26
+ mod query_result;
26
27
  mod store;
27
28
  mod utils;
28
29
  mod value;
@@ -32,11 +33,14 @@ mod value_table;
32
33
  pub(crate) mod tests;
33
34
 
34
35
  pub use {
35
- connection::Connection,
36
+ connection::{Backend, Connection},
36
37
  error::{CompileTimeError, Error, RunTimeError, StoreError},
37
- graph::{Edge, Node, Path},
38
- value::{Value, ValueMap},
38
+ graph::{labels, Edge, Node, Path},
39
+ query_result::QueryResult,
40
+ value::{array, value_map, Value, ValueMap, ValueTryIntoRef},
39
41
  };
40
42
 
43
+ pub use graphcore::{table, Table};
44
+
41
45
  /// GQLite Result alias. Usable as a standard `Result<T, E>` or default to gqlite::Error with `Result<T>`
42
46
  pub type Result<T, E = error::export::Error> = std::result::Result<T, E>;
@@ -60,7 +60,7 @@ impl VariableIdentifiers
60
60
  .next_id
61
61
  .fetch_add(1, std::sync::atomic::Ordering::Relaxed)
62
62
  }
63
- pub(crate) fn from_name(&self, name: impl Into<String>) -> VariableIdentifier
63
+ pub(crate) fn create_variable_from_name(&self, name: impl Into<String>) -> VariableIdentifier
64
64
  {
65
65
  let name = name.into();
66
66
  match self.identifiers.borrow_mut().entry(name)
@@ -77,11 +77,14 @@ impl VariableIdentifiers
77
77
  }
78
78
  }
79
79
  }
80
- pub(crate) fn from_name_optional(&self, name: Option<String>) -> Option<VariableIdentifier>
80
+ pub(crate) fn create_variable_from_name_optional(
81
+ &self,
82
+ name: Option<String>,
83
+ ) -> Option<VariableIdentifier>
81
84
  {
82
- name.map(|name| self.from_name(name))
85
+ name.map(|name| self.create_variable_from_name(name))
83
86
  }
84
- pub(crate) fn anonymous(&self) -> VariableIdentifier
87
+ pub(crate) fn create_anonymous_variable(&self) -> VariableIdentifier
85
88
  {
86
89
  let id = self.next_id();
87
90
  VariableIdentifier {
@@ -95,6 +98,7 @@ impl VariableIdentifiers
95
98
  pub(crate) enum Statement
96
99
  {
97
100
  CreateGraph(CreateGraph),
101
+ DropGraph(DropGraph),
98
102
  UseGraph(UseGraph),
99
103
  Create(Create),
100
104
  Match(Match),
@@ -106,13 +110,13 @@ pub(crate) enum Statement
106
110
  Update(Update),
107
111
  }
108
112
 
109
- macro_rules! create_into_statement {
113
+ macro_rules! create_from_statement {
110
114
  ( $x:tt ) => {
111
- impl Into<Statement> for $x
115
+ impl From<$x> for Statement
112
116
  {
113
- fn into(self) -> Statement
117
+ fn from(v: $x) -> Statement
114
118
  {
115
- Statement::$x(self)
119
+ Statement::$x(v)
116
120
  }
117
121
  }
118
122
  };
@@ -122,12 +126,16 @@ pub(crate) type Statements = Vec<Statement>;
122
126
  pub(crate) type Queries = Vec<Statements>;
123
127
 
124
128
  #[derive(Debug)]
125
- pub(crate) enum Node {}
129
+ pub(crate) struct CreateGraph
130
+ {
131
+ pub(crate) name: String,
132
+ }
126
133
 
127
134
  #[derive(Debug)]
128
- pub(crate) struct CreateGraph
135
+ pub(crate) struct DropGraph
129
136
  {
130
137
  pub(crate) name: String,
138
+ pub(crate) if_exists: bool,
131
139
  }
132
140
 
133
141
  #[derive(Debug)]
@@ -142,7 +150,7 @@ pub(crate) struct Create
142
150
  pub(crate) patterns: Vec<Pattern>,
143
151
  }
144
152
 
145
- create_into_statement! {Create}
153
+ create_from_statement! {Create}
146
154
 
147
155
  #[derive(Debug)]
148
156
  pub(crate) struct Match
@@ -152,7 +160,7 @@ pub(crate) struct Match
152
160
  pub(crate) optional: bool,
153
161
  }
154
162
 
155
- create_into_statement! {Match}
163
+ create_from_statement! {Match}
156
164
 
157
165
  #[derive(Debug)]
158
166
  pub(crate) struct Return
@@ -163,7 +171,7 @@ pub(crate) struct Return
163
171
  pub(crate) where_expression: Option<Expression>,
164
172
  }
165
173
 
166
- create_into_statement! {Return}
174
+ create_from_statement! {Return}
167
175
 
168
176
  #[derive(Debug)]
169
177
  pub(crate) struct With
@@ -174,7 +182,7 @@ pub(crate) struct With
174
182
  pub(crate) where_expression: Option<Expression>,
175
183
  }
176
184
 
177
- create_into_statement! {With}
185
+ create_from_statement! {With}
178
186
 
179
187
  #[derive(Debug)]
180
188
  pub(crate) struct Unwind
@@ -183,7 +191,7 @@ pub(crate) struct Unwind
183
191
  pub(crate) expression: Expression,
184
192
  }
185
193
 
186
- create_into_statement! {Unwind}
194
+ create_from_statement! {Unwind}
187
195
 
188
196
  #[derive(Debug)]
189
197
  pub(crate) struct Delete
@@ -198,18 +206,11 @@ pub(crate) struct Update
198
206
  pub(crate) updates: Vec<OneUpdate>,
199
207
  }
200
208
 
201
- #[derive(Debug)]
202
- pub(crate) struct Remove
203
- {
204
- pub(crate) expressions: Vec<Expression>,
205
- }
206
-
207
209
  #[derive(Debug)]
208
210
  pub(crate) struct Call
209
211
  {
210
212
  pub(crate) name: String,
211
213
  pub(crate) arguments: Vec<Expression>,
212
- pub(crate) yield_: Vec<String>,
213
214
  }
214
215
 
215
216
  // Set/remove Statements
@@ -265,6 +266,7 @@ pub(crate) struct Modifiers
265
266
  // Expressions
266
267
 
267
268
  #[derive(Debug, Clone, PartialEq)]
269
+ #[allow(clippy::large_enum_variant)]
268
270
  pub(crate) enum Expression
269
271
  {
270
272
  Array(Array),
@@ -294,6 +296,7 @@ pub(crate) enum Expression
294
296
  Multiplication(Box<Multiplication>),
295
297
  Division(Box<Division>),
296
298
  Modulo(Box<Modulo>),
299
+ Exponent(Box<Exponent>),
297
300
 
298
301
  Negation(Box<Negation>),
299
302
  LogicalNegation(Box<LogicalNegation>),
@@ -350,9 +353,10 @@ pub(crate) struct PathPattern
350
353
  #[derive(Debug, Clone, PartialEq)]
351
354
  pub(crate) enum LabelExpression
352
355
  {
356
+ #[allow(dead_code)]
353
357
  Not(Box<LabelExpression>),
354
- And(Vec<Box<LabelExpression>>),
355
- Or(Vec<Box<LabelExpression>>),
358
+ And(Vec<LabelExpression>),
359
+ Or(Vec<LabelExpression>),
356
360
  String(String),
357
361
  None,
358
362
  }
@@ -374,7 +378,7 @@ impl LabelExpression
374
378
  }
375
379
  other =>
376
380
  {
377
- vec.push(other.boxed());
381
+ vec.push(other);
378
382
  LabelExpression::And(vec)
379
383
  }
380
384
  },
@@ -383,10 +387,10 @@ impl LabelExpression
383
387
  LabelExpression::None => self,
384
388
  LabelExpression::And(mut vec) =>
385
389
  {
386
- vec.push(self.boxed());
390
+ vec.push(self);
387
391
  LabelExpression::And(vec)
388
392
  }
389
- _ => LabelExpression::And(vec![self.boxed(), rhs.boxed()]),
393
+ _ => LabelExpression::And(vec![self, rhs]),
390
394
  },
391
395
  }
392
396
  }
@@ -405,7 +409,7 @@ impl LabelExpression
405
409
  }
406
410
  other =>
407
411
  {
408
- vec.push(other.boxed());
412
+ vec.push(other);
409
413
  LabelExpression::Or(vec)
410
414
  }
411
415
  },
@@ -414,21 +418,13 @@ impl LabelExpression
414
418
  LabelExpression::None => self,
415
419
  LabelExpression::Or(mut vec) =>
416
420
  {
417
- vec.push(self.boxed());
421
+ vec.push(self);
418
422
  LabelExpression::Or(vec)
419
423
  }
420
- _ => LabelExpression::Or(vec![self.boxed(), rhs.boxed()]),
424
+ _ => LabelExpression::Or(vec![self, rhs]),
421
425
  },
422
426
  }
423
427
  }
424
- fn clone_boxed(&self) -> Box<LabelExpression>
425
- {
426
- self.clone().boxed()
427
- }
428
- pub(crate) fn boxed(self) -> Box<LabelExpression>
429
- {
430
- Box::new(self)
431
- }
432
428
  pub(crate) fn is_all_inclusive(&self) -> bool
433
429
  {
434
430
  match self
@@ -442,43 +438,35 @@ impl LabelExpression
442
438
  }
443
439
  pub(crate) fn is_none(&self) -> bool
444
440
  {
445
- match self
446
- {
447
- LabelExpression::None => true,
448
- _ => false,
449
- }
441
+ matches!(self, LabelExpression::None)
450
442
  }
451
443
  pub(crate) fn is_string(&self) -> bool
452
444
  {
453
- match self
454
- {
455
- LabelExpression::String(_) => true,
456
- _ => false,
457
- }
445
+ matches!(self, LabelExpression::String(_))
458
446
  }
459
447
  }
460
448
 
461
449
  // Expressions
462
450
 
463
- macro_rules! create_into_expr {
451
+ macro_rules! create_from_expr {
464
452
  ( $x:tt ) => {
465
- impl Into<Expression> for $x
453
+ impl From<$x> for Expression
466
454
  {
467
- fn into(self) -> Expression
455
+ fn from(v: $x) -> Expression
468
456
  {
469
- Expression::$x(self)
457
+ Expression::$x(v)
470
458
  }
471
459
  }
472
460
  };
473
461
  }
474
462
 
475
- macro_rules! create_into_boxed_expr {
463
+ macro_rules! create_from_boxed_expr {
476
464
  ( $x:tt ) => {
477
- impl Into<Expression> for $x
465
+ impl From<$x> for Expression
478
466
  {
479
- fn into(self) -> Expression
467
+ fn from(v: $x) -> Expression
480
468
  {
481
- Expression::$x(Box::new(self))
469
+ Expression::$x(Box::new(v))
482
470
  }
483
471
  }
484
472
  };
@@ -503,7 +491,7 @@ pub(crate) struct Variable
503
491
  pub(crate) identifier: VariableIdentifier,
504
492
  }
505
493
 
506
- create_into_expr! {Variable}
494
+ create_from_expr! {Variable}
507
495
 
508
496
  #[derive(Debug, Clone, PartialEq)]
509
497
  pub(crate) struct MemberAccess
@@ -512,7 +500,7 @@ pub(crate) struct MemberAccess
512
500
  pub(crate) path: Vec<String>,
513
501
  }
514
502
 
515
- create_into_boxed_expr! {MemberAccess}
503
+ create_from_boxed_expr! {MemberAccess}
516
504
 
517
505
  #[derive(Debug, Clone, PartialEq)]
518
506
  pub(crate) struct IndexAccess
@@ -521,7 +509,7 @@ pub(crate) struct IndexAccess
521
509
  pub(crate) index: Expression,
522
510
  }
523
511
 
524
- create_into_boxed_expr! {IndexAccess}
512
+ create_from_boxed_expr! {IndexAccess}
525
513
 
526
514
  #[derive(Debug, Clone, PartialEq)]
527
515
  pub(crate) struct RangeAccess
@@ -530,12 +518,6 @@ pub(crate) struct RangeAccess
530
518
  pub(crate) start: Option<Expression>,
531
519
  pub(crate) end: Option<Expression>,
532
520
  }
533
- #[derive(Debug)]
534
- pub(crate) struct HasLabels
535
- {
536
- pub(crate) left: String,
537
- pub(crate) labels: Vec<String>,
538
- }
539
521
 
540
522
  #[derive(Debug, Clone, PartialEq)]
541
523
  pub(crate) struct FunctionCall
@@ -544,7 +526,7 @@ pub(crate) struct FunctionCall
544
526
  pub(crate) arguments: Vec<Expression>,
545
527
  }
546
528
 
547
- create_into_expr! {FunctionCall}
529
+ create_from_expr! {FunctionCall}
548
530
 
549
531
  macro_rules! create_binary_op {
550
532
  ( $x:tt ) => {
@@ -555,7 +537,7 @@ macro_rules! create_binary_op {
555
537
  pub(crate) right: Expression,
556
538
  }
557
539
 
558
- create_into_boxed_expr! { $x }
540
+ create_from_boxed_expr! { $x }
559
541
  };
560
542
  }
561
543
 
@@ -576,6 +558,7 @@ create_binary_op! {Subtraction}
576
558
  create_binary_op! {Multiplication}
577
559
  create_binary_op! {Division}
578
560
  create_binary_op! {Modulo}
561
+ create_binary_op! {Exponent}
579
562
 
580
563
  macro_rules! create_unary_op {
581
564
  ( $x:tt ) => {
@@ -584,7 +567,7 @@ macro_rules! create_unary_op {
584
567
  {
585
568
  pub(crate) value: Expression,
586
569
  }
587
- create_into_boxed_expr! { $x }
570
+ create_from_boxed_expr! { $x }
588
571
  };
589
572
  }
590
573
 
@@ -595,18 +578,13 @@ create_unary_op! {IsNotNull}
595
578
 
596
579
  // Values
597
580
 
598
- #[derive(Debug)]
599
- pub(crate) struct All {}
600
- #[derive(Debug)]
601
- pub(crate) struct EndOfList {}
602
-
603
581
  #[derive(Debug, Clone, PartialEq)]
604
582
  pub(crate) struct Value
605
583
  {
606
584
  pub(crate) value: crate::value::Value,
607
585
  }
608
586
 
609
- create_into_expr! {Value}
587
+ create_from_expr! {Value}
610
588
 
611
589
  #[derive(Debug, Clone, PartialEq)]
612
590
  pub(crate) struct Map
@@ -614,7 +592,7 @@ pub(crate) struct Map
614
592
  pub(crate) map: Vec<(String, Expression)>,
615
593
  }
616
594
 
617
- create_into_expr! {Map}
595
+ create_from_expr! {Map}
618
596
 
619
597
  #[derive(Debug, Clone, PartialEq)]
620
598
  pub(crate) struct Array
@@ -622,4 +600,4 @@ pub(crate) struct Array
622
600
  pub(crate) array: Vec<Expression>,
623
601
  }
624
602
 
625
- create_into_expr! {Array}
603
+ create_from_expr! {Array}
@@ -29,7 +29,7 @@ nothing = { nothing_ident? }
29
29
  // fragments
30
30
 
31
31
  labels = { ":" ~ label_expression }
32
- pattern = { ident? ~ labels? ~ map? }
32
+ pattern = { ident? ~ labels? ~ (map | parameter)? }
33
33
  node_pattern = { "(" ~ pattern ~ ")" }
34
34
 
35
35
  directed_edge_pattern = { (")-[" ~ pattern ~ "]->(") | (nothing ~ ")-->(") }
@@ -64,6 +64,8 @@ where_modifier = { "WHERE" ~ expression }
64
64
  // Statements
65
65
  statement = {
66
66
  create_graph_statement
67
+ | drop_graph_if_exists_statement
68
+ | drop_graph_statement
67
69
  | use_graph_statement
68
70
  | create_statement
69
71
  | optional_match_statement
@@ -81,6 +83,8 @@ statement = {
81
83
  star = { "*" }
82
84
 
83
85
  create_graph_statement = { "CREATE" ~ "GRAPH" ~ ident }
86
+ drop_graph_statement = { "DROP" ~ "GRAPH" ~ ident }
87
+ drop_graph_if_exists_statement = { "DROP" ~ "GRAPH" ~ "IF" ~ "EXISTS" ~ ident }
84
88
  use_graph_statement = { "USE" ~ ident }
85
89
 
86
90
  create_statement = { "CREATE" ~ node_or_edge_pattern ~ ("," ~ node_or_edge_pattern)* }
@@ -121,7 +125,7 @@ remove_member_access = { (("(" ~ ident ~ ")") | ident) ~ ("." ~ ident)+ }
121
125
 
122
126
  expression = { prefix* ~ expression_term ~ postfix* ~ (infix ~ prefix? ~ expression_term ~ postfix*)* }
123
127
 
124
- infix = _{ addition | subtraction | multiplication | division | modulo | or | and | xor | equal | different | in_ | not_in | superior_equal | inferior_equal | superior | inferior }
128
+ infix = _{ addition | subtraction | multiplication | division | modulo | exponent | or | and | xor | equal | different | in_ | not_in | superior_equal | inferior_equal | superior | inferior }
125
129
  postfix = _{ is_null | is_not_null | member_access | range_access | range_access_to | index_access }
126
130
  prefix = _{ negation | not }
127
131
 
@@ -130,6 +134,7 @@ subtraction = { "-" }
130
134
  multiplication = { "*" }
131
135
  division = { "/" }
132
136
  modulo = { "%" }
137
+ exponent = { "^" }
133
138
 
134
139
  xor_kw = @{ "XOR" ~ !ASCII_ALPHA }
135
140
  xor = { xor_kw }
@@ -164,8 +169,8 @@ label_check_expression = { ident ~ (":" ~ ident)+ }
164
169
  parenthesised_expression = { "(" ~ expression ~ ")" }
165
170
  named_expression = { (expression ~ "AS" ~ ident) | expression }
166
171
  function_call = { function_name ~ "(" ~ (expression ~ ("," ~ expression)*)? ~ ")" }
167
- count_star = { "count" ~ "(" ~ "*" ~ ")" }
168
- expression_term = { null_lit | true_lit | false_lit | num | hexa_int | octa_int | int | string_literal | map | array | label_check_expression | parameter | parenthesised_expression | function_call | count_star | ident }
172
+ function_star = { function_name ~ "(" ~ "*" ~ ")" }
173
+ expression_term = { null_lit | true_lit | false_lit | num | hexa_int | octa_int | int | string_literal | map | array | label_check_expression | parameter | parenthesised_expression | function_call | function_star | ident }
169
174
 
170
175
  parameter = { "$" ~ parameter_name }
171
176