gqlite 1.3.1 → 1.4.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 (40) hide show
  1. checksums.yaml +4 -4
  2. data/ext/Cargo.toml +3 -3
  3. data/ext/gqlitedb/Cargo.toml +5 -2
  4. data/ext/gqlitedb/src/aggregators/arithmetic.rs +1 -0
  5. data/ext/gqlitedb/src/compiler/expression_analyser.rs +2 -0
  6. data/ext/gqlitedb/src/compiler.rs +1 -0
  7. data/ext/gqlitedb/src/connection.rs +42 -7
  8. data/ext/gqlitedb/src/error.rs +3 -0
  9. data/ext/gqlitedb/src/interpreter/evaluators.rs +5 -2
  10. data/ext/gqlitedb/src/interpreter/instructions.rs +1 -1
  11. data/ext/gqlitedb/src/lib.rs +1 -1
  12. data/ext/gqlitedb/src/parser/ast.rs +1 -0
  13. data/ext/gqlitedb/src/parser/gql.pest +3 -1
  14. data/ext/gqlitedb/src/parser/parser_impl.rs +8 -0
  15. data/ext/gqlitedb/src/prelude.rs +3 -0
  16. data/ext/gqlitedb/src/store/{pgql.rs → pgrx.rs} +2 -0
  17. data/ext/gqlitedb/src/store/postgres.rs +0 -0
  18. data/ext/gqlitedb/src/store/sqlbase/sqlmetadata.rs +117 -0
  19. data/ext/gqlitedb/src/store/sqlbase/sqlqueries.rs +62 -0
  20. data/ext/gqlitedb/src/store/sqlbase/sqlstore.rs +55 -0
  21. data/ext/gqlitedb/src/store/sqlbase/sqlvalue.rs +189 -0
  22. data/ext/gqlitedb/src/store/sqlbase.rs +456 -0
  23. data/ext/gqlitedb/src/store/sqlite.rs +271 -573
  24. data/ext/gqlitedb/src/store.rs +7 -5
  25. data/ext/gqlitedb/src/utils.rs +25 -0
  26. data/ext/gqlitedb/src/value/compare.rs +6 -0
  27. data/ext/gqlitedb/src/value.rs +18 -2
  28. data/ext/gqlitedb/templates/sql/sqlite/edge_select.sql +18 -18
  29. data/ext/gqlitedb/templates/sql/sqlite/edge_update.sql +3 -3
  30. data/ext/gqlitedb/templates/sql/sqlite/node_select.sql +6 -6
  31. data/ext/gqlitedb/templates/sql/sqlite/node_update.sql +3 -3
  32. data/ext/gqliterb/src/lib.rs +30 -0
  33. data/ext/graphcore/Cargo.toml +3 -2
  34. data/ext/graphcore/src/error.rs +2 -0
  35. data/ext/graphcore/src/lib.rs +2 -0
  36. data/ext/graphcore/src/prelude.rs +1 -1
  37. data/ext/graphcore/src/timestamp.rs +104 -0
  38. data/ext/graphcore/src/value.rs +106 -23
  39. metadata +15 -5
  40. data/ext/graphcore/release.toml +0 -1
@@ -8,6 +8,7 @@ use std::{
8
8
  mod value_map;
9
9
 
10
10
  pub(crate) use crate::prelude::*;
11
+ use crate::TimeStamp;
11
12
 
12
13
  pub use value_map::ValueMap;
13
14
 
@@ -33,6 +34,8 @@ pub enum Value
33
34
  Float(f64),
34
35
  /// String value.
35
36
  String(String),
37
+ /// Timestamp value
38
+ TimeStamp(timestamp::TimeStamp),
36
39
  /// Array of values.
37
40
  Array(Vec<Value>),
38
41
  /// Unordered map of values.
@@ -97,6 +100,7 @@ impl Hash for Value
97
100
  bits.hash(state);
98
101
  }
99
102
  Value::String(s) => s.hash(state),
103
+ Value::TimeStamp(ts) => ts.hash(state),
100
104
  Value::Array(a) => a.hash(state),
101
105
  Value::Map(m) => m.hash(state),
102
106
  Value::Node(n) => n.hash(state),
@@ -118,6 +122,7 @@ impl Add for Value
118
122
  | Value::Node(..)
119
123
  | Value::Edge(..)
120
124
  | Value::Map(..)
125
+ | Value::TimeStamp(..)
121
126
  | Value::Path(..) => Err(Error::InvalidBinaryOperands),
122
127
  Value::Null => Ok(Value::Null),
123
128
  Self::Array(lhs) => match rhs
@@ -171,6 +176,7 @@ macro_rules! impl_mdsr {
171
176
  Value::Boolean(..)
172
177
  | Value::Key(..)
173
178
  | Value::String(..)
179
+ | Value::TimeStamp(..)
174
180
  | Value::Node(..)
175
181
  | Value::Edge(..)
176
182
  | Value::Array(..)
@@ -212,6 +218,7 @@ impl Value
212
218
  Value::Boolean(..)
213
219
  | Value::Key(..)
214
220
  | Value::String(..)
221
+ | Value::TimeStamp(..)
215
222
  | Value::Node(..)
216
223
  | Value::Edge(..)
217
224
  | Value::Array(..)
@@ -255,6 +262,7 @@ impl Neg for Value
255
262
  | Value::String(..)
256
263
  | Value::Node(..)
257
264
  | Value::Edge(..)
265
+ | Value::TimeStamp(..)
258
266
  | Value::Array(..)
259
267
  | Value::Map(..)
260
268
  | Value::Path(..) => Err(Error::InvalidNegationOperands),
@@ -274,6 +282,7 @@ impl std::fmt::Display for Value
274
282
  Value::Integer(i) => write!(f, "{}", i),
275
283
  Value::Float(fl) => write!(f, "{}", fl),
276
284
  Value::String(s) => write!(f, "{}", s),
285
+ Value::TimeStamp(t) => write!(f, "{}", t),
277
286
  Value::Array(v) => write!(f, "[{}]", v.iter().map(|x| x.to_string()).join(", ")),
278
287
  Value::Map(o) => write!(f, "{}", o),
279
288
  Value::Node(n) => write!(f, "{}", n),
@@ -298,7 +307,42 @@ impl ValueTryIntoRef<Value> for Value
298
307
  }
299
308
  }
300
309
 
301
- macro_rules! impl_to_value {
310
+ impl<T> From<Option<T>> for Value
311
+ where
312
+ Value: From<T>,
313
+ {
314
+ fn from(value: Option<T>) -> Self
315
+ {
316
+ match value
317
+ {
318
+ Some(value) => value.into(),
319
+ None => Value::Null,
320
+ }
321
+ }
322
+ }
323
+
324
+ macro_rules! impl_from_value {
325
+ ($type:ty, $vn:tt, try) => {
326
+ impl_from_value!($type, $vn);
327
+ impl TryFrom<Value> for $type
328
+ {
329
+ type Error = Error;
330
+ fn try_from(value: Value) -> Result<$type, Self::Error>
331
+ {
332
+ match value
333
+ {
334
+ Value::$vn(v) => Ok(v),
335
+ _ => Err(
336
+ Error::InvalidValueCast {
337
+ value: Box::new(value),
338
+ typename: stringify!($type),
339
+ }
340
+ .into(),
341
+ ),
342
+ }
343
+ }
344
+ }
345
+ };
302
346
  ($type:ty, $vn:tt) => {
303
347
  impl From<$type> for Value
304
348
  {
@@ -315,25 +359,38 @@ macro_rules! impl_to_value {
315
359
  Value::Array(v.into_iter().map(|v| v.into()).collect())
316
360
  }
317
361
  }
318
- impl TryInto<$type> for Value
362
+ impl TryFrom<&Value> for $type
319
363
  {
320
364
  type Error = Error;
321
- fn try_into(self) -> Result<$type, Self::Error>
365
+ fn try_from(value: &Value) -> Result<$type, Self::Error>
322
366
  {
323
- match self
367
+ <$type>::try_from(value.to_owned())
368
+ }
369
+ }
370
+ impl TryFrom<Value> for Option<$type>
371
+ {
372
+ type Error = Error;
373
+ fn try_from(value: Value) -> Result<Self>
374
+ {
375
+ match value
324
376
  {
325
- Value::$vn(v) => Ok(v),
326
- _ => Err(
327
- Error::InvalidValueCast {
328
- value: Box::new(self),
329
- typename: stringify!($type),
330
- }
331
- .into(),
332
- ),
377
+ Value::Null => Ok(None),
378
+ _ =>
379
+ {
380
+ let t: $type = value.try_into()?;
381
+ Ok(Some(t))
382
+ }
333
383
  }
334
384
  }
335
385
  }
336
-
386
+ impl TryFrom<&Value> for Option<$type>
387
+ {
388
+ type Error = Error;
389
+ fn try_from(value: &Value) -> Result<Option<$type>, Self::Error>
390
+ {
391
+ <Option<$type>>::try_from(value.to_owned())
392
+ }
393
+ }
337
394
  impl ValueTryIntoRef<$type> for Value
338
395
  {
339
396
  fn try_into_ref(&self) -> Result<&$type, Error>
@@ -354,16 +411,42 @@ macro_rules! impl_to_value {
354
411
  };
355
412
  }
356
413
 
357
- impl_to_value!(graph::Key, Key);
358
- impl_to_value!(bool, Boolean);
359
- impl_to_value!(i64, Integer);
360
- impl_to_value!(f64, Float);
361
- impl_to_value!(String, String);
362
- impl_to_value!(graph::Node, Node);
363
- impl_to_value!(graph::Edge, Edge);
364
- impl_to_value!(graph::SinglePath, Path);
365
- impl_to_value!(Vec<Value>, Array);
366
- impl_to_value!(ValueMap, Map);
414
+ impl_from_value!(graph::Key, Key, try);
415
+ impl_from_value!(bool, Boolean, try);
416
+ impl_from_value!(i64, Integer, try);
417
+ impl_from_value!(f64, Float, try);
418
+ impl_from_value!(String, String, try);
419
+ impl_from_value!(TimeStamp, TimeStamp);
420
+ impl_from_value!(graph::Node, Node, try);
421
+ impl_from_value!(graph::Edge, Edge, try);
422
+ impl_from_value!(graph::SinglePath, Path, try);
423
+ impl_from_value!(Vec<Value>, Array, try);
424
+ impl_from_value!(ValueMap, Map, try);
425
+
426
+ impl TryFrom<Value> for TimeStamp
427
+ {
428
+ type Error = Error;
429
+ fn try_from(value: Value) -> Result<TimeStamp, Self::Error>
430
+ {
431
+ match value
432
+ {
433
+ Value::String(s) => Ok(TimeStamp::parse(&s)?),
434
+ Value::TimeStamp(v) => Ok(v),
435
+ _ => Err(Error::InvalidValueCast {
436
+ value: Box::new(value),
437
+ typename: stringify!($type),
438
+ }),
439
+ }
440
+ }
441
+ }
442
+
443
+ impl From<()> for Value
444
+ {
445
+ fn from(_: ()) -> Self
446
+ {
447
+ Self::Null
448
+ }
449
+ }
367
450
 
368
451
  impl From<&str> for Value
369
452
  {
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gqlite
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyrille Berger
8
+ autorequire:
8
9
  bindir: bin
9
10
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
11
+ date: 2025-11-11 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: rb_sys
@@ -55,6 +56,7 @@ description: "GQLite is a Rust-language library, with a C interface, that implem
55
56
  => ex\n # Report any error\n puts \"An error has occured: #{ex.message}\"\nend\n\n```\n\nThe
56
57
  documentation for the GQL query language can found in [OpenCypher](https://auksys.org/documentation/5/libraries/gqlite/opencypher/)
57
58
  and for the [API](https://auksys.org/documentation/5/libraries/gqlite/api/).\n\n"
59
+ email:
58
60
  executables: []
59
61
  extensions:
60
62
  - ext/gqliterb/extconf.rb
@@ -101,8 +103,14 @@ files:
101
103
  - ext/gqlitedb/src/prelude.rs
102
104
  - ext/gqlitedb/src/query_result.rs
103
105
  - ext/gqlitedb/src/store.rs
104
- - ext/gqlitedb/src/store/pgql.rs
106
+ - ext/gqlitedb/src/store/pgrx.rs
107
+ - ext/gqlitedb/src/store/postgres.rs
105
108
  - ext/gqlitedb/src/store/redb.rs
109
+ - ext/gqlitedb/src/store/sqlbase.rs
110
+ - ext/gqlitedb/src/store/sqlbase/sqlmetadata.rs
111
+ - ext/gqlitedb/src/store/sqlbase/sqlqueries.rs
112
+ - ext/gqlitedb/src/store/sqlbase/sqlstore.rs
113
+ - ext/gqlitedb/src/store/sqlbase/sqlvalue.rs
106
114
  - ext/gqlitedb/src/store/sqlite.rs
107
115
  - ext/gqlitedb/src/tests.rs
108
116
  - ext/gqlitedb/src/tests/compiler.rs
@@ -143,13 +151,13 @@ files:
143
151
  - ext/gqliterb/src/lib.rs
144
152
  - ext/graphcore/Cargo.toml
145
153
  - ext/graphcore/README.MD
146
- - ext/graphcore/release.toml
147
154
  - ext/graphcore/src/error.rs
148
155
  - ext/graphcore/src/graph.rs
149
156
  - ext/graphcore/src/lib.rs
150
157
  - ext/graphcore/src/prelude.rs
151
158
  - ext/graphcore/src/serialize_with.rs
152
159
  - ext/graphcore/src/table.rs
160
+ - ext/graphcore/src/timestamp.rs
153
161
  - ext/graphcore/src/value.rs
154
162
  - ext/graphcore/src/value/value_map.rs
155
163
  - lib/gqlite.rb
@@ -157,6 +165,7 @@ homepage: https://gitlab.com/auksys/gqlite
157
165
  licenses:
158
166
  - MIT
159
167
  metadata: {}
168
+ post_install_message:
160
169
  rdoc_options: []
161
170
  require_paths:
162
171
  - lib
@@ -171,7 +180,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
171
180
  - !ruby/object:Gem::Version
172
181
  version: '0'
173
182
  requirements: []
174
- rubygems_version: 3.6.7
183
+ rubygems_version: 3.4.20
184
+ signing_key:
175
185
  specification_version: 4
176
186
  summary: Ruby bindings for GQLite, a Graph Query library.
177
187
  test_files: []
@@ -1 +0,0 @@
1
- tag = false