activegraph 11.3.1 → 11.5.0.alpha.1
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/CHANGELOG.md +6 -0
- data/Gemfile +1 -1
- data/activegraph.gemspec +3 -3
- data/lib/active_graph/attribute_set.rb +0 -4
- data/lib/active_graph/base.rb +0 -3
- data/lib/active_graph/config.rb +0 -1
- data/lib/active_graph/core/instrumentable.rb +0 -5
- data/lib/active_graph/core/querable.rb +0 -5
- data/lib/active_graph/core/query.rb +6 -9
- data/lib/active_graph/core/query_clauses.rb +65 -7
- data/lib/active_graph/core/query_ext.rb +1 -1
- data/lib/active_graph/core/record.rb +0 -5
- data/lib/active_graph/core/result.rb +5 -0
- data/lib/active_graph/core/wrappable.rb +1 -1
- data/lib/active_graph/generators/active_model.rb +33 -0
- data/lib/active_graph/generators/generated_attribute.rb +17 -0
- data/lib/{rails/generators/active_graph/migration → active_graph/generators}/migration_generator.rb +0 -4
- data/lib/{rails/generators/active_graph_generator.rb → active_graph/generators/migration_helper.rb} +0 -75
- data/lib/{rails/generators/active_graph/model → active_graph/generators}/model_generator.rb +0 -4
- data/lib/active_graph/generators/source_path_helper.rb +10 -0
- data/lib/{rails/generators/active_graph/upgrade_v8 → active_graph/generators}/upgrade_v8_generator.rb +0 -4
- data/lib/active_graph/lazy_attribute_hash.rb +0 -2
- data/lib/active_graph/migration.rb +0 -3
- data/lib/active_graph/migrations/helpers.rb +0 -7
- data/lib/active_graph/migrations/runner.rb +0 -4
- data/lib/active_graph/migrations.rb +0 -8
- data/lib/active_graph/model_schema.rb +0 -1
- data/lib/active_graph/node/has_n/association.rb +0 -3
- data/lib/active_graph/node/labels.rb +1 -3
- data/lib/active_graph/node/orm_adapter.rb +0 -6
- data/lib/active_graph/node/query/{query_proxy_link.rb → query_proxy/link.rb} +92 -0
- data/lib/active_graph/node/query/query_proxy.rb +20 -3
- data/lib/active_graph/node/scope.rb +4 -43
- data/lib/active_graph/node/wrapping.rb +52 -0
- data/lib/active_graph/node.rb +1 -0
- data/lib/active_graph/railtie.rb +0 -6
- data/lib/active_graph/relationship/property.rb +0 -2
- data/lib/active_graph/relationship/wrapping.rb +26 -0
- data/lib/active_graph/shared/attributes.rb +3 -2
- data/lib/active_graph/shared/node_query_factory.rb +15 -0
- data/lib/active_graph/shared/persistence.rb +1 -1
- data/lib/active_graph/shared/query_factory.rb +0 -60
- data/lib/active_graph/shared/rel_query_factory.rb +47 -0
- data/lib/active_graph/shared/type_converters.rb +0 -6
- data/lib/active_graph/tasks/migration.rake +0 -4
- data/lib/active_graph/timestamps.rb +0 -3
- data/lib/active_graph/version.rb +1 -1
- data/lib/active_graph.rb +43 -114
- metadata +31 -22
- data/lib/active_graph/core.rb +0 -14
- data/lib/active_graph/node/node_wrapper.rb +0 -54
- data/lib/active_graph/relationship/rel_wrapper.rb +0 -31
- data/lib/active_graph/wrapper.rb +0 -4
- /data/lib/active_graph/{errors.rb → error.rb} +0 -0
- /data/lib/{rails/generators/active_graph → active_graph/generators}/migration/templates/migration.erb +0 -0
- /data/lib/{rails/generators/active_graph → active_graph/generators}/model/templates/migration.erb +0 -0
- /data/lib/{rails/generators/active_graph → active_graph/generators}/model/templates/model.erb +0 -0
- /data/lib/{rails/generators/active_graph → active_graph/generators}/upgrade_v8/templates/migration.erb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0101891bd10ab15f40fe0b95d8f9801addbad38e6a9a620d6ed3172538f13b81'
|
4
|
+
data.tar.gz: 29cd3cdd821bdd01723767210820b441d175c20722d086791e3b6f96c60e7860
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 236ae57612400438f2ea424600e5b4013790d9fe77840421727f83e5158ca4c8622cc8b2bda502d19c8f212956c86111f25b38fe5d3a68e2ef4819620432aa53
|
7
|
+
data.tar.gz: e699e3c4788af542fec9c1b74552b08309a8bd3611a25232445c0bf8a7a4f292067ee3cb86db5c7ed7a34dc134eff8a1fea59c772b778a58de2b1c3d1ec47bb1
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file.
|
|
3
3
|
This file should follow the standards specified on [http://keepachangelog.com/]
|
4
4
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
5
5
|
|
6
|
+
## [11.4.0] 2023-02-12
|
7
|
+
|
8
|
+
## Fixed
|
9
|
+
|
10
|
+
- Added support for cypher UNION
|
11
|
+
|
6
12
|
## [11.3.1] 2023-02-12
|
7
13
|
|
8
14
|
## Fixed
|
data/Gemfile
CHANGED
@@ -4,7 +4,7 @@ gemspec
|
|
4
4
|
|
5
5
|
# gem 'neo4j-ruby-driver', path: '../neo4j-ruby-driver'
|
6
6
|
|
7
|
-
gem 'listen', '< 3.1'
|
7
|
+
# gem 'listen', '< 3.1'
|
8
8
|
|
9
9
|
active_model_version = ENV['ACTIVE_MODEL_VERSION']
|
10
10
|
gem 'activemodel', "~> #{active_model_version}" if active_model_version&.length&.positive?
|
data/activegraph.gemspec
CHANGED
@@ -33,8 +33,8 @@ DESCRIPTION
|
|
33
33
|
s.add_dependency('activemodel', '>= 4.0')
|
34
34
|
s.add_dependency('activesupport', '>= 4.0')
|
35
35
|
s.add_dependency('i18n', '!= 1.8.8') # https://github.com/jruby/jruby/issues/6547
|
36
|
-
s.add_dependency('neo4j-ruby-driver', '>= 4.4.1')
|
37
|
-
s.add_dependency('orm_adapter', '
|
36
|
+
s.add_dependency('neo4j-ruby-driver', '>= 4.4.1', '< 5')
|
37
|
+
s.add_dependency('orm_adapter', '>= 0.5.0')
|
38
38
|
s.add_dependency('sorted_set')
|
39
39
|
s.add_development_dependency('guard')
|
40
40
|
s.add_development_dependency('guard-rspec')
|
@@ -47,5 +47,5 @@ DESCRIPTION
|
|
47
47
|
s.add_development_dependency('rubocop', '>= 0.56.0')
|
48
48
|
s.add_development_dependency('yard')
|
49
49
|
s.add_development_dependency('dryspec')
|
50
|
-
s.add_development_dependency('rspec', '
|
50
|
+
s.add_development_dependency('rspec', '>= 3.10')
|
51
51
|
end
|
data/lib/active_graph/base.rb
CHANGED
data/lib/active_graph/config.rb
CHANGED
@@ -1,7 +1,3 @@
|
|
1
|
-
require 'active_graph/core/query_clauses'
|
2
|
-
require 'active_graph/core/query_find_in_batches'
|
3
|
-
require 'active_support/notifications'
|
4
|
-
|
5
1
|
module ActiveGraph
|
6
2
|
module Core
|
7
3
|
# Allows for generation of cypher queries via ruby method calls (inspired by ActiveRecord / arel syntax)
|
@@ -15,9 +11,9 @@ module ActiveGraph
|
|
15
11
|
class Query
|
16
12
|
include ActiveGraph::Core::QueryClauses
|
17
13
|
include ActiveGraph::Core::QueryFindInBatches
|
14
|
+
include QueryExt
|
18
15
|
DEFINED_CLAUSES = {}
|
19
16
|
|
20
|
-
|
21
17
|
attr_accessor :clauses
|
22
18
|
|
23
19
|
class Parameters
|
@@ -162,8 +158,8 @@ module ActiveGraph
|
|
162
158
|
# DETACH DELETE clause
|
163
159
|
# @return [Query]
|
164
160
|
|
165
|
-
METHODS = %w[start match optional_match call using where create create_unique merge set on_create_set on_match_set remove unwind delete detach_delete with with_distinct return order skip limit] # rubocop:disable
|
166
|
-
BREAK_METHODS = %(with with_distinct call)
|
161
|
+
METHODS = %w[start match optional_match call using where create create_unique merge set on_create_set on_match_set remove unwind delete detach_delete with with_distinct return order skip limit union call_subquery_start call_subquery_end] # rubocop:disable Layout/LineLength
|
162
|
+
BREAK_METHODS = %w(with with_distinct call call_subquery_start call_subquery_end)
|
167
163
|
|
168
164
|
CLAUSIFY_CLAUSE = proc { |method| const_get(method.to_s.split('_').map(&:capitalize).join + 'Clause') }
|
169
165
|
CLAUSES = METHODS.map(&CLAUSIFY_CLAUSE)
|
@@ -247,7 +243,7 @@ module ActiveGraph
|
|
247
243
|
neo_id = (node_object.respond_to?(:neo_id) ? node_object.neo_id : node_object)
|
248
244
|
|
249
245
|
match_method = optional_match ? :optional_match : :match
|
250
|
-
query.send(match_method, variable).where(variable => {neo_id:
|
246
|
+
query.send(match_method, variable).where(variable => { neo_id: })
|
251
247
|
end
|
252
248
|
end
|
253
249
|
|
@@ -271,7 +267,6 @@ module ActiveGraph
|
|
271
267
|
# @return [Array]
|
272
268
|
# @raise [ActiveGraph::Server::CypherResponse::ResponseError] Raises errors from neo4j server
|
273
269
|
|
274
|
-
|
275
270
|
# Executes a query without returning the result
|
276
271
|
# @return [Boolean] true if successful
|
277
272
|
# @raise [ActiveGraph::Server::CypherResponse::ResponseError] Raises errors from neo4j server
|
@@ -318,6 +313,7 @@ module ActiveGraph
|
|
318
313
|
# @return [String] Resulting cypher query string
|
319
314
|
EMPTY = ' '
|
320
315
|
NEWLINE = "\n"
|
316
|
+
|
321
317
|
def to_cypher(options = {})
|
322
318
|
join_string = options[:pretty] ? NEWLINE : EMPTY
|
323
319
|
|
@@ -334,6 +330,7 @@ module ActiveGraph
|
|
334
330
|
cypher_string = "CYPHER #{@options[:parser]} #{cypher_string}" if @options[:parser]
|
335
331
|
cypher_string.tap(&:strip!)
|
336
332
|
end
|
333
|
+
|
337
334
|
alias cypher to_cypher
|
338
335
|
|
339
336
|
def pretty_cypher
|
@@ -28,7 +28,7 @@ module ActiveGraph
|
|
28
28
|
def value
|
29
29
|
return @value if @value
|
30
30
|
|
31
|
-
[String, Symbol, Integer, Hash, NilClass].each do |arg_class|
|
31
|
+
[String, Symbol, Integer, Hash, NilClass, Array].each do |arg_class|
|
32
32
|
from_method = "from_#{arg_class.name.downcase}"
|
33
33
|
return @value = send(from_method, @arg) if @arg.is_a?(arg_class) && respond_to?(from_method)
|
34
34
|
end
|
@@ -130,13 +130,15 @@ module ActiveGraph
|
|
130
130
|
def to_cypher(clauses, pretty = false)
|
131
131
|
string = clause_string(clauses, pretty)
|
132
132
|
|
133
|
-
final_keyword
|
134
|
-
|
135
|
-
else
|
136
|
-
keyword
|
137
|
-
end
|
133
|
+
"#{final_keyword(pretty)} #{string}" if !string.empty?
|
134
|
+
end
|
138
135
|
|
139
|
-
|
136
|
+
def final_keyword(pretty)
|
137
|
+
if pretty
|
138
|
+
"#{clause_color}#{keyword}#{ANSI::CLEAR}"
|
139
|
+
else
|
140
|
+
keyword
|
141
|
+
end
|
140
142
|
end
|
141
143
|
|
142
144
|
def clause_string(clauses, pretty)
|
@@ -256,6 +258,30 @@ module ActiveGraph
|
|
256
258
|
end
|
257
259
|
end
|
258
260
|
|
261
|
+
class UnionClause < Clause
|
262
|
+
KEYWORD = ''
|
263
|
+
|
264
|
+
def from_array(args)
|
265
|
+
"#{args[1]} RETURN #{args[0]} AS #{args.last}"
|
266
|
+
end
|
267
|
+
|
268
|
+
class << self
|
269
|
+
def from_args(args, params, options = {})
|
270
|
+
params.add_params(args[2])
|
271
|
+
|
272
|
+
[from_arg(args, params, options)]
|
273
|
+
end
|
274
|
+
|
275
|
+
def clause_strings(clauses)
|
276
|
+
clauses.map!(&:value)
|
277
|
+
end
|
278
|
+
|
279
|
+
def clause_join
|
280
|
+
' UNION '
|
281
|
+
end
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
259
285
|
class WhereClause < Clause
|
260
286
|
KEYWORD = 'WHERE'
|
261
287
|
|
@@ -349,6 +375,38 @@ module ActiveGraph
|
|
349
375
|
end
|
350
376
|
end
|
351
377
|
|
378
|
+
class CallSubqueryStartClause < Clause
|
379
|
+
KEYWORD = 'CALL {'
|
380
|
+
|
381
|
+
def from_nilclass(_value)
|
382
|
+
' '
|
383
|
+
end
|
384
|
+
|
385
|
+
def from_string(value)
|
386
|
+
value
|
387
|
+
end
|
388
|
+
|
389
|
+
class << self
|
390
|
+
def to_cypher(clauses, pretty = false)
|
391
|
+
super || final_keyword(pretty)
|
392
|
+
end
|
393
|
+
|
394
|
+
def clause_strings(clauses)
|
395
|
+
clauses.map!(&:value)
|
396
|
+
end
|
397
|
+
end
|
398
|
+
end
|
399
|
+
|
400
|
+
class CallSubqueryEndClause < Clause
|
401
|
+
KEYWORD = '}'
|
402
|
+
|
403
|
+
class << self
|
404
|
+
def to_cypher(_clauses, pretty = false)
|
405
|
+
final_keyword(pretty)
|
406
|
+
end
|
407
|
+
end
|
408
|
+
end
|
409
|
+
|
352
410
|
class MatchClause < Clause
|
353
411
|
KEYWORD = 'MATCH'
|
354
412
|
|
@@ -0,0 +1,33 @@
|
|
1
|
+
class ActiveGraph::Generators::ActiveModel < Rails::Generators::ActiveModel #:nodoc:
|
2
|
+
def self.all(klass)
|
3
|
+
"#{klass}.all"
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.find(klass, params = nil)
|
7
|
+
"#{klass}.find(#{params})"
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.build(klass, params = nil)
|
11
|
+
if params
|
12
|
+
"#{klass}.new(#{params})"
|
13
|
+
else
|
14
|
+
"#{klass}.new"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def save
|
19
|
+
"#{name}.save"
|
20
|
+
end
|
21
|
+
|
22
|
+
def update_attributes(params = nil)
|
23
|
+
"#{name}.update_attributes(#{params})"
|
24
|
+
end
|
25
|
+
|
26
|
+
def errors
|
27
|
+
"#{name}.errors"
|
28
|
+
end
|
29
|
+
|
30
|
+
def destroy
|
31
|
+
"#{name}.destroy"
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module ActiveGraph
|
2
|
+
module Generators
|
3
|
+
module GeneratedAttribute #:nodoc:
|
4
|
+
def type_class
|
5
|
+
case type.to_s.downcase
|
6
|
+
when 'any' then 'any'
|
7
|
+
when 'datetime' then 'DateTime'
|
8
|
+
when 'date' then 'Date'
|
9
|
+
when 'integer', 'number', 'fixnum' then 'Integer'
|
10
|
+
when 'float' then 'Float'
|
11
|
+
else
|
12
|
+
'String'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/{rails/generators/active_graph_generator.rb → active_graph/generators/migration_helper.rb}
RENAMED
@@ -1,13 +1,3 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'rails/generators/named_base'
|
4
|
-
require 'rails/generators/active_model'
|
5
|
-
|
6
|
-
module ActiveGraph
|
7
|
-
module Generators #:nodoc:
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
1
|
module ActiveGraph::Generators::MigrationHelper
|
12
2
|
extend ActiveSupport::Concern
|
13
3
|
|
@@ -54,68 +44,3 @@ module ActiveGraph::Generators::MigrationHelper
|
|
54
44
|
FileUtils.rm(real_file_name) if @behavior == :revoke
|
55
45
|
end
|
56
46
|
end
|
57
|
-
|
58
|
-
module ActiveGraph::Generators::SourcePathHelper
|
59
|
-
extend ActiveSupport::Concern
|
60
|
-
|
61
|
-
module ClassMethods
|
62
|
-
def source_root
|
63
|
-
@_neo4j_source_root ||= File.expand_path(File.join(File.dirname(__FILE__),
|
64
|
-
'active_graph', generator_name, 'templates'))
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
|
70
|
-
class ActiveGraph::Generators::ActiveModel < Rails::Generators::ActiveModel #:nodoc:
|
71
|
-
def self.all(klass)
|
72
|
-
"#{klass}.all"
|
73
|
-
end
|
74
|
-
|
75
|
-
def self.find(klass, params = nil)
|
76
|
-
"#{klass}.find(#{params})"
|
77
|
-
end
|
78
|
-
|
79
|
-
def self.build(klass, params = nil)
|
80
|
-
if params
|
81
|
-
"#{klass}.new(#{params})"
|
82
|
-
else
|
83
|
-
"#{klass}.new"
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def save
|
88
|
-
"#{name}.save"
|
89
|
-
end
|
90
|
-
|
91
|
-
def update_attributes(params = nil)
|
92
|
-
"#{name}.update_attributes(#{params})"
|
93
|
-
end
|
94
|
-
|
95
|
-
def errors
|
96
|
-
"#{name}.errors"
|
97
|
-
end
|
98
|
-
|
99
|
-
def destroy
|
100
|
-
"#{name}.destroy"
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
|
105
|
-
module Rails
|
106
|
-
module Generators
|
107
|
-
class GeneratedAttribute #:nodoc:
|
108
|
-
def type_class
|
109
|
-
case type.to_s.downcase
|
110
|
-
when 'any' then 'any'
|
111
|
-
when 'datetime' then 'DateTime'
|
112
|
-
when 'date' then 'Date'
|
113
|
-
when 'integer', 'number', 'fixnum' then 'Integer'
|
114
|
-
when 'float' then 'Float'
|
115
|
-
else
|
116
|
-
'String'
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
@@ -1,7 +1,3 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'active_graph.rb')
|
4
|
-
|
5
1
|
class ActiveGraph::Generators::ModelGenerator < Rails::Generators::NamedBase #:nodoc:
|
6
2
|
include ::ActiveGraph::Generators::SourcePathHelper
|
7
3
|
include ::ActiveGraph::Generators::MigrationHelper
|
@@ -1,14 +1,7 @@
|
|
1
|
-
require 'benchmark'
|
2
|
-
|
3
1
|
module ActiveGraph
|
4
2
|
module Migrations
|
5
3
|
module Helpers
|
6
4
|
extend ActiveSupport::Concern
|
7
|
-
extend ActiveSupport::Autoload
|
8
|
-
|
9
|
-
autoload :Schema
|
10
|
-
autoload :IdProperty
|
11
|
-
autoload :Relationships
|
12
5
|
|
13
6
|
PROPERTY_ALREADY_DEFINED = 'Property `%{new_property}` is already defined in `%{label}`. '\
|
14
7
|
'To overwrite, call `remove_property(:%{label}, :%{new_property})` before this method.'.freeze
|
@@ -1,13 +1,5 @@
|
|
1
1
|
module ActiveGraph
|
2
2
|
module Migrations
|
3
|
-
extend ActiveSupport::Autoload
|
4
|
-
autoload :Helpers
|
5
|
-
autoload :MigrationFile
|
6
|
-
autoload :Base
|
7
|
-
autoload :Runner
|
8
|
-
autoload :SchemaMigration
|
9
|
-
autoload :CheckPending
|
10
|
-
|
11
3
|
class << self
|
12
4
|
def check_for_pending_migrations!
|
13
5
|
return if ActiveGraph::Config.configuration['skip_migration_check']
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'active_graph/core/label'
|
2
|
-
|
3
1
|
module ActiveGraph
|
4
2
|
module Node
|
5
3
|
# Provides a mapping between neo4j labels and Ruby classes
|
@@ -76,7 +74,7 @@ module ActiveGraph
|
|
76
74
|
|
77
75
|
def self.clear_wrapped_models
|
78
76
|
MODELS_FOR_LABELS_CACHE.clear
|
79
|
-
ActiveGraph::
|
77
|
+
ActiveGraph::Node::Wrapping::CONSTANTS_FOR_LABELS_CACHE.clear
|
80
78
|
end
|
81
79
|
|
82
80
|
module ClassMethods
|