activecypher 0.3.0 → 0.5.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.
- checksums.yaml +4 -4
- data/lib/active_cypher/base.rb +1 -1
- data/lib/active_cypher/bolt/session.rb +62 -50
- data/lib/active_cypher/bolt/transaction.rb +92 -87
- data/lib/active_cypher/connection_adapters/abstract_bolt_adapter.rb +40 -32
- data/lib/active_cypher/connection_adapters/neo4j_adapter.rb +1 -1
- data/lib/active_cypher/cypher_config.rb +2 -1
- data/lib/active_cypher/generators/node_generator.rb +32 -3
- data/lib/active_cypher/generators/relationship_generator.rb +29 -2
- data/lib/active_cypher/generators/templates/node.rb.erb +10 -6
- data/lib/active_cypher/generators/templates/relationship.rb.erb +7 -6
- data/lib/active_cypher/instrumentation.rb +186 -0
- data/lib/active_cypher/model/connection_owner.rb +15 -0
- data/lib/active_cypher/model/core.rb +58 -4
- data/lib/active_cypher/model/countable.rb +10 -3
- data/lib/active_cypher/model/destruction.rb +17 -10
- data/lib/active_cypher/model/persistence.rb +28 -8
- data/lib/active_cypher/model/querying.rb +5 -1
- data/lib/active_cypher/relation.rb +10 -2
- data/lib/active_cypher/version.rb +1 -1
- data/lib/cyrel/clause/set.rb +20 -10
- data/lib/cyrel/expression/property_access.rb +2 -0
- data/lib/cyrel/plus.rb +11 -0
- data/lib/cyrel/query.rb +1 -0
- data/lib/cyrel.rb +77 -18
- metadata +3 -1
data/lib/cyrel.rb
CHANGED
@@ -1,72 +1,131 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'irb' # Required for binding.irb
|
4
|
-
|
5
3
|
module Cyrel
|
6
4
|
module_function
|
7
5
|
|
8
|
-
#
|
6
|
+
# Cyrel DSL helper: creates a CALL clause for a procedure.
|
7
|
+
# Example: Cyrel.call('db.labels')
|
9
8
|
def call(procedure)
|
10
9
|
CallProcedure.new(procedure)
|
11
10
|
end
|
12
11
|
|
12
|
+
# Cyrel DSL helper: creates a RETURN clause.
|
13
|
+
# Example: Cyrel.return(name: :n)
|
13
14
|
def return(**return_values)
|
14
15
|
ReturnOnly.new(return_values)
|
15
16
|
end
|
16
|
-
# Now make all defined instance methods module functions
|
17
17
|
|
18
|
-
#
|
18
|
+
# Cyrel DSL helper: creates a node pattern.
|
19
|
+
# Example: Cyrel.node(:n, labels: ['Person'], properties: {name: 'Alice'})
|
19
20
|
def node(alias_name, labels: [], properties: {})
|
20
21
|
Pattern::Node.new(alias_name, labels: labels, properties: properties)
|
21
22
|
end
|
22
|
-
# Add helpers for Relationship, Path if needed
|
23
23
|
|
24
|
-
#
|
24
|
+
# Cyrel DSL helper: starts a CREATE query.
|
25
|
+
# Example: Cyrel.create(pattern)
|
25
26
|
def create(pattern)
|
26
|
-
Query.new.create(pattern)
|
27
|
+
Query.new.create(pattern)
|
27
28
|
end
|
28
29
|
|
30
|
+
# Cyrel DSL helper: starts a MATCH query.
|
31
|
+
# Example: Cyrel.match(pattern)
|
29
32
|
def match(pattern, path_variable: nil)
|
30
|
-
Query.new.match(pattern, path_variable: path_variable)
|
33
|
+
Query.new.match(pattern, path_variable: path_variable)
|
31
34
|
end
|
32
|
-
# Add helpers for merge etc. if desired as query starters
|
33
35
|
|
34
|
-
#
|
35
|
-
#
|
36
|
-
# Delegate to the correct module function
|
36
|
+
# Cyrel DSL helper: returns the element id of a node/relationship.
|
37
|
+
# Example: Cyrel.id(:n)
|
37
38
|
def id(...) = Functions.element_id(...)
|
39
|
+
|
40
|
+
# Cyrel DSL helper: returns the element id of a node/relationship (alias).
|
38
41
|
def element_id(...) = Functions.element_id(...)
|
42
|
+
|
43
|
+
# Cyrel DSL helper: Cypher count() aggregation.
|
44
|
+
# Example: Cyrel.count(:n)
|
39
45
|
def count(...) = Functions.count(...)
|
46
|
+
|
47
|
+
# Cyrel DSL helper: Cypher labels() function.
|
48
|
+
# Example: Cyrel.labels(:n)
|
40
49
|
def labels(...) = Functions.labels(...)
|
50
|
+
|
51
|
+
# Cyrel DSL helper: Cypher type() function.
|
52
|
+
# Example: Cyrel.type(:r)
|
41
53
|
def type(...) = Functions.type(...)
|
54
|
+
|
55
|
+
# Cyrel DSL helper: Cypher properties() function.
|
56
|
+
# Example: Cyrel.properties(:n)
|
42
57
|
def properties(...) = Functions.properties(...)
|
58
|
+
|
59
|
+
# Cyrel DSL helper: Cypher coalesce() function.
|
60
|
+
# Example: Cyrel.coalesce(:a, :b)
|
43
61
|
def coalesce(...) = Functions.coalesce(...)
|
62
|
+
|
63
|
+
# Cyrel DSL helper: Cypher timestamp() function.
|
64
|
+
# Example: Cyrel.timestamp
|
44
65
|
def timestamp(...) = Functions.timestamp(...)
|
66
|
+
|
67
|
+
# Cyrel DSL helper: Cypher toString() function.
|
68
|
+
# Example: Cyrel.to_string(:n)
|
45
69
|
def to_string(...) = Functions.to_string(...)
|
70
|
+
|
71
|
+
# Cyrel DSL helper: Cypher toInteger() function.
|
72
|
+
# Example: Cyrel.to_integer(:n)
|
46
73
|
def to_integer(...) = Functions.to_integer(...)
|
74
|
+
|
75
|
+
# Cyrel DSL helper: Cypher toFloat() function.
|
76
|
+
# Example: Cyrel.to_float(:n)
|
47
77
|
def to_float(...) = Functions.to_float(...)
|
78
|
+
|
79
|
+
# Cyrel DSL helper: Cypher toBoolean() function.
|
80
|
+
# Example: Cyrel.to_boolean(:n)
|
48
81
|
def to_boolean(...) = Functions.to_boolean(...)
|
82
|
+
|
83
|
+
# Cyrel DSL helper: Cypher sum() aggregation.
|
84
|
+
# Example: Cyrel.sum(:n)
|
49
85
|
def sum(...) = Functions.sum(...)
|
86
|
+
|
87
|
+
# Cyrel DSL helper: Cypher avg() aggregation.
|
88
|
+
# Example: Cyrel.avg(:n)
|
50
89
|
def avg(...) = Functions.avg(...)
|
90
|
+
|
91
|
+
# Cyrel DSL helper: Cypher min() aggregation.
|
92
|
+
# Example: Cyrel.min(:n)
|
51
93
|
def min(...) = Functions.min(...)
|
94
|
+
|
95
|
+
# Cyrel DSL helper: Cypher max() aggregation.
|
96
|
+
# Example: Cyrel.max(:n)
|
52
97
|
def max(...) = Functions.max(...)
|
98
|
+
|
99
|
+
# Cyrel DSL helper: Cypher collect() aggregation.
|
100
|
+
# Example: Cyrel.collect(:n)
|
53
101
|
def collect(...) = Functions.collect(...)
|
54
|
-
def size(...) = Functions.size(...)
|
55
102
|
|
56
|
-
#
|
103
|
+
# Cyrel DSL helper: Cypher size() function.
|
104
|
+
# Example: Cyrel.size(:n)
|
105
|
+
def size(...) = Functions.size(...)
|
57
106
|
|
58
|
-
#
|
107
|
+
# Cyrel DSL helper: creates a PropertyAccess expression.
|
108
|
+
# Example: Cyrel.prop(:n, :name)
|
59
109
|
def prop(variable, property_name)
|
60
110
|
Expression.prop(variable, property_name)
|
61
111
|
end
|
62
112
|
|
63
|
-
#
|
113
|
+
# Cyrel DSL helper: creates an Exists expression.
|
114
|
+
# Example: Cyrel.exists(pattern)
|
64
115
|
def exists(pattern)
|
65
116
|
Expression.exists(pattern)
|
66
117
|
end
|
67
118
|
|
68
|
-
#
|
119
|
+
# Cyrel DSL helper: creates a Logical NOT expression.
|
120
|
+
# Example: Cyrel.not(expression)
|
69
121
|
def not(expression)
|
70
122
|
Expression.not(expression)
|
71
123
|
end
|
124
|
+
|
125
|
+
# Cyrel DSL helper: property merging (SET n += {props}).
|
126
|
+
# Use for updating only specified properties on a node or relationship.
|
127
|
+
# Example: Cyrel.plus(:n) => { name: "Alice" } generates SET n += $p1
|
128
|
+
def plus(variable)
|
129
|
+
Plus.new(variable)
|
130
|
+
end
|
72
131
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activecypher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Abdelkader Boudih
|
@@ -132,6 +132,7 @@ files:
|
|
132
132
|
- lib/active_cypher/generators/templates/cypher_databases.yml
|
133
133
|
- lib/active_cypher/generators/templates/node.rb.erb
|
134
134
|
- lib/active_cypher/generators/templates/relationship.rb.erb
|
135
|
+
- lib/active_cypher/instrumentation.rb
|
135
136
|
- lib/active_cypher/logging.rb
|
136
137
|
- lib/active_cypher/model/abstract.rb
|
137
138
|
- lib/active_cypher/model/attributes.rb
|
@@ -189,6 +190,7 @@ files:
|
|
189
190
|
- lib/cyrel/pattern/node.rb
|
190
191
|
- lib/cyrel/pattern/path.rb
|
191
192
|
- lib/cyrel/pattern/relationship.rb
|
193
|
+
- lib/cyrel/plus.rb
|
192
194
|
- lib/cyrel/query.rb
|
193
195
|
- lib/cyrel/return_only.rb
|
194
196
|
- lib/cyrel/types/hash_type.rb
|