activegraph 10.0.0.pre.alpha.11 → 10.0.0.pre.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/{neo4j.gemspec → activegraph.gemspec} +7 -9
- data/config/neo4j/config.yml +4 -4
- data/lib/active_graph.rb +120 -0
- data/lib/{neo4j → active_graph}/ansi.rb +1 -1
- data/lib/{neo4j → active_graph}/attribute_set.rb +3 -3
- data/lib/{neo4j/active_base.rb → active_graph/base.rb} +18 -12
- data/lib/{neo4j → active_graph}/class_arguments.rb +5 -5
- data/lib/{neo4j → active_graph}/config.rb +10 -10
- data/lib/active_graph/core.rb +14 -0
- data/lib/{neo4j → active_graph}/core/connection_failed_error.rb +1 -1
- data/lib/{neo4j → active_graph}/core/cypher_error.rb +1 -1
- data/lib/{neo4j → active_graph}/core/driver.rb +5 -5
- data/lib/{neo4j → active_graph}/core/has_uri.rb +1 -1
- data/lib/{neo4j → active_graph}/core/instrumentable.rb +4 -4
- data/lib/{neo4j → active_graph}/core/label.rb +13 -13
- data/lib/{neo4j → active_graph}/core/logging.rb +2 -2
- data/lib/{neo4j → active_graph}/core/node.rb +2 -2
- data/lib/{neo4j → active_graph}/core/querable.rb +7 -7
- data/lib/{neo4j → active_graph}/core/query.rb +16 -16
- data/lib/{neo4j → active_graph}/core/query_builder.rb +3 -3
- data/lib/{neo4j → active_graph}/core/query_clauses.rb +1 -1
- data/lib/{neo4j → active_graph}/core/query_ext.rb +5 -5
- data/lib/{neo4j → active_graph}/core/query_find_in_batches.rb +2 -2
- data/lib/{neo4j → active_graph}/core/relationship.rb +2 -2
- data/lib/{neo4j → active_graph}/core/responses.rb +3 -3
- data/lib/{neo4j → active_graph}/core/result.rb +1 -1
- data/lib/{neo4j → active_graph}/core/schema.rb +1 -1
- data/lib/{neo4j → active_graph}/core/schema_errors.rb +1 -1
- data/lib/{neo4j → active_graph}/core/wrappable.rb +1 -1
- data/lib/{neo4j → active_graph}/errors.rb +1 -1
- data/lib/{neo4j → active_graph}/lazy_attribute_hash.rb +1 -1
- data/lib/{neo4j → active_graph}/migration.rb +11 -11
- data/lib/{neo4j → active_graph}/migrations.rb +5 -5
- data/lib/{neo4j → active_graph}/migrations/base.rb +7 -7
- data/lib/{neo4j → active_graph}/migrations/check_pending.rb +3 -3
- data/lib/{neo4j → active_graph}/migrations/helpers.rb +4 -4
- data/lib/{neo4j → active_graph}/migrations/helpers/id_property.rb +3 -3
- data/lib/{neo4j → active_graph}/migrations/helpers/relationships.rb +1 -1
- data/lib/{neo4j → active_graph}/migrations/helpers/schema.rb +7 -7
- data/lib/{neo4j → active_graph}/migrations/migration_file.rb +1 -1
- data/lib/{neo4j → active_graph}/migrations/runner.rb +3 -3
- data/lib/{neo4j → active_graph}/migrations/schema.rb +1 -1
- data/lib/{neo4j → active_graph}/migrations/schema_migration.rb +2 -2
- data/lib/{neo4j → active_graph}/model_schema.rb +8 -8
- data/lib/{neo4j/active_node.rb → active_graph/node.rb} +32 -32
- data/lib/{neo4j/active_node → active_graph/node}/callbacks.rb +3 -3
- data/lib/{neo4j/active_node → active_graph/node}/dependent.rb +2 -2
- data/lib/{neo4j/active_node → active_graph/node}/dependent/association_methods.rb +2 -2
- data/lib/{neo4j/active_node → active_graph/node}/dependent/query_proxy_methods.rb +4 -4
- data/lib/{neo4j/active_node → active_graph/node}/dependent_callbacks.rb +4 -4
- data/lib/{neo4j/active_node → active_graph/node}/enum.rb +3 -3
- data/lib/{neo4j/active_node → active_graph/node}/has_n.rb +20 -20
- data/lib/{neo4j/active_node → active_graph/node}/has_n/association.rb +8 -8
- data/lib/{neo4j/active_node → active_graph/node}/has_n/association/rel_factory.rb +4 -4
- data/lib/{neo4j/active_node → active_graph/node}/has_n/association/rel_wrapper.rb +4 -4
- data/lib/{neo4j/active_node → active_graph/node}/has_n/association_cypher_methods.rb +2 -2
- data/lib/{neo4j/active_node → active_graph/node}/id_property.rb +7 -7
- data/lib/{neo4j/active_node → active_graph/node}/id_property/accessor.rb +1 -1
- data/lib/{neo4j/active_node → active_graph/node}/initialize.rb +3 -3
- data/lib/{neo4j/active_node → active_graph/node}/labels.rb +18 -18
- data/lib/{neo4j/active_node → active_graph/node}/labels/index.rb +6 -6
- data/lib/{neo4j/active_node → active_graph/node}/labels/reloading.rb +1 -1
- data/lib/{neo4j/active_node → active_graph/node}/node_list_formatter.rb +1 -1
- data/lib/{neo4j/active_node → active_graph/node}/node_wrapper.rb +5 -5
- data/lib/{neo4j/active_node → active_graph/node}/orm_adapter.rb +2 -2
- data/lib/{neo4j/active_node → active_graph/node}/persistence.rb +7 -7
- data/lib/{neo4j/active_node → active_graph/node}/property.rb +3 -3
- data/lib/{neo4j/active_node → active_graph/node}/query.rb +9 -9
- data/lib/{neo4j/active_node → active_graph/node}/query/query_proxy.rb +19 -19
- data/lib/{neo4j/active_node → active_graph/node}/query/query_proxy_eager_loading.rb +3 -3
- data/lib/{neo4j/active_node → active_graph/node}/query/query_proxy_eager_loading/association_tree.rb +2 -2
- data/lib/{neo4j/active_node → active_graph/node}/query/query_proxy_enumerable.rb +4 -4
- data/lib/{neo4j/active_node → active_graph/node}/query/query_proxy_find_in_batches.rb +2 -2
- data/lib/{neo4j/active_node → active_graph/node}/query/query_proxy_link.rb +3 -3
- data/lib/{neo4j/active_node → active_graph/node}/query/query_proxy_methods.rb +12 -12
- data/lib/{neo4j/active_node → active_graph/node}/query/query_proxy_methods_of_mass_updating.rb +4 -4
- data/lib/{neo4j/active_node → active_graph/node}/query_methods.rb +4 -4
- data/lib/{neo4j/active_node → active_graph/node}/reflection.rb +3 -3
- data/lib/{neo4j/active_node → active_graph/node}/rels.rb +1 -1
- data/lib/{neo4j/active_node → active_graph/node}/scope.rb +4 -4
- data/lib/{neo4j/active_node → active_graph/node}/unpersisted.rb +2 -2
- data/lib/{neo4j/active_node → active_graph/node}/validations.rb +3 -3
- data/lib/{neo4j → active_graph}/paginated.rb +1 -1
- data/lib/{neo4j → active_graph}/railtie.rb +18 -18
- data/lib/{neo4j/active_rel.rb → active_graph/relationship.rb} +19 -19
- data/lib/active_graph/relationship/callbacks.rb +21 -0
- data/lib/{neo4j/active_rel → active_graph/relationship}/initialize.rb +5 -5
- data/lib/{neo4j/active_rel → active_graph/relationship}/persistence.rb +6 -6
- data/lib/{neo4j/active_rel → active_graph/relationship}/persistence/query_factory.rb +7 -7
- data/lib/{neo4j/active_rel → active_graph/relationship}/property.rb +6 -6
- data/lib/{neo4j/active_rel → active_graph/relationship}/query.rb +7 -7
- data/lib/{neo4j/active_rel → active_graph/relationship}/rel_wrapper.rb +5 -5
- data/lib/{neo4j/active_rel → active_graph/relationship}/related_node.rb +7 -7
- data/lib/{neo4j/active_rel → active_graph/relationship}/types.rb +6 -6
- data/lib/active_graph/relationship/validations.rb +8 -0
- data/lib/{neo4j → active_graph}/schema/operation.rb +5 -5
- data/lib/{neo4j → active_graph}/shared.rb +7 -7
- data/lib/{neo4j → active_graph}/shared/attributes.rb +10 -10
- data/lib/{neo4j → active_graph}/shared/callbacks.rb +3 -3
- data/lib/{neo4j → active_graph}/shared/cypher.rb +1 -1
- data/lib/{neo4j → active_graph}/shared/declared_properties.rb +8 -8
- data/lib/{neo4j → active_graph}/shared/declared_property.rb +9 -9
- data/lib/{neo4j → active_graph}/shared/declared_property/index.rb +3 -3
- data/lib/{neo4j → active_graph}/shared/enum.rb +6 -6
- data/lib/{neo4j → active_graph}/shared/filtered_hash.rb +2 -2
- data/lib/{neo4j → active_graph}/shared/identity.rb +2 -2
- data/lib/{neo4j → active_graph}/shared/initialize.rb +3 -3
- data/lib/{neo4j → active_graph}/shared/marshal.rb +1 -1
- data/lib/{neo4j → active_graph}/shared/mass_assignment.rb +2 -2
- data/lib/{neo4j → active_graph}/shared/permitted_attributes.rb +1 -1
- data/lib/{neo4j → active_graph}/shared/persistence.rb +4 -4
- data/lib/{neo4j → active_graph}/shared/property.rb +10 -10
- data/lib/{neo4j → active_graph}/shared/query_factory.rb +5 -5
- data/lib/{neo4j → active_graph}/shared/rel_type_converters.rb +6 -6
- data/lib/{neo4j → active_graph}/shared/serialized_properties.rb +1 -1
- data/lib/{neo4j → active_graph}/shared/type_converters.rb +11 -13
- data/lib/{neo4j → active_graph}/shared/typecasted_attributes.rb +7 -7
- data/lib/{neo4j → active_graph}/shared/typecaster.rb +3 -3
- data/lib/{neo4j → active_graph}/shared/validations.rb +1 -1
- data/lib/{neo4j → active_graph}/tasks/migration.rake +25 -25
- data/lib/{neo4j → active_graph}/timestamps.rb +3 -3
- data/lib/{neo4j → active_graph}/timestamps/created.rb +1 -1
- data/lib/{neo4j → active_graph}/timestamps/updated.rb +1 -1
- data/lib/{neo4j → active_graph}/transaction.rb +9 -9
- data/lib/active_graph/transactions.rb +54 -0
- data/lib/{neo4j → active_graph}/type_converters.rb +2 -2
- data/lib/{neo4j → active_graph}/undeclared_properties.rb +1 -1
- data/lib/active_graph/version.rb +3 -0
- data/lib/{neo4j → active_graph}/wrapper.rb +1 -1
- data/lib/rails/generators/neo4j/migration/migration_generator.rb +4 -4
- data/lib/rails/generators/neo4j/migration/templates/migration.erb +2 -2
- data/lib/rails/generators/neo4j/model/model_generator.rb +4 -4
- data/lib/rails/generators/neo4j/model/templates/migration.erb +1 -1
- data/lib/rails/generators/neo4j/model/templates/model.erb +1 -1
- data/lib/rails/generators/neo4j/upgrade_v8/templates/migration.erb +1 -1
- data/lib/rails/generators/neo4j/upgrade_v8/upgrade_v8_generator.rb +6 -6
- data/lib/rails/generators/neo4j_generator.rb +4 -4
- metadata +134 -133
- data/lib/neo4j.rb +0 -119
- data/lib/neo4j/active_rel/callbacks.rb +0 -21
- data/lib/neo4j/active_rel/validations.rb +0 -8
- data/lib/neo4j/core.rb +0 -14
- data/lib/neo4j/version.rb +0 -3
@@ -1,14 +1,14 @@
|
|
1
1
|
require 'active_support/core_ext/module/attribute_accessors'
|
2
|
-
require '
|
3
|
-
require '
|
4
|
-
require '
|
2
|
+
require 'active_graph/core/logging'
|
3
|
+
require 'active_graph/core/has_uri'
|
4
|
+
require 'active_graph/version'
|
5
5
|
|
6
|
-
module
|
6
|
+
module ActiveGraph
|
7
7
|
module Core
|
8
8
|
class Driver
|
9
9
|
include HasUri
|
10
10
|
|
11
|
-
USER_AGENT_STRING = "neo4j-gem/#{::
|
11
|
+
USER_AGENT_STRING = "neo4j-gem/#{::ActiveGraph::VERSION} (https://github.com/neo4jrb/neo4j)"
|
12
12
|
|
13
13
|
attr_accessor :wrap_level
|
14
14
|
attr_reader :options, :driver
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'active_support/concern'
|
2
2
|
require 'active_support/notifications'
|
3
|
-
require '
|
3
|
+
require 'active_graph/ansi'
|
4
4
|
|
5
|
-
module
|
5
|
+
module ActiveGraph
|
6
6
|
module Core
|
7
7
|
module Instrumentable
|
8
8
|
extend ActiveSupport::Concern
|
@@ -14,7 +14,7 @@ module Neo4j
|
|
14
14
|
def subscribe_to_request
|
15
15
|
ActiveSupport::Notifications.subscribe('neo4j.core.bolt.request') do |_, start, finish, _id, _payload|
|
16
16
|
ms = (finish - start) * 1000
|
17
|
-
yield " #{ANSI::BLUE}BOLT:#{ANSI::CLEAR} #{ANSI::YELLOW}#{ms.round}ms#{ANSI::CLEAR} #{
|
17
|
+
yield " #{ANSI::BLUE}BOLT:#{ANSI::CLEAR} #{ANSI::YELLOW}#{ms.round}ms#{ANSI::CLEAR} #{Base.current_driver.url_without_password}"
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -27,7 +27,7 @@ module Neo4j
|
|
27
27
|
source_line, line_number = Logging.first_external_path_and_line(caller_locations)
|
28
28
|
|
29
29
|
yield " #{ANSI::CYAN}#{query.context || 'CYPHER'}#{ANSI::CLEAR} #{cypher} #{params_string}" +
|
30
|
-
("\n ↳ #{source_line}:#{line_number}" if
|
30
|
+
("\n ↳ #{source_line}:#{line_number}" if Base.current_driver.options[:verbose_query_logs] && source_line).to_s
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module ActiveGraph
|
2
2
|
module Core
|
3
3
|
class Label
|
4
4
|
attr_reader :name
|
@@ -21,7 +21,7 @@ module Neo4j
|
|
21
21
|
# Creates a neo4j constraint on a property
|
22
22
|
# See http://docs.neo4j.org/chunked/stable/query-constraints.html
|
23
23
|
# @example
|
24
|
-
# label =
|
24
|
+
# label = ActiveGraph::Label.create(:person, driver)
|
25
25
|
# label.create_constraint(:name, {type: :unique}, driver)
|
26
26
|
#
|
27
27
|
def create_constraint(property, constraints)
|
@@ -41,7 +41,7 @@ module Neo4j
|
|
41
41
|
# Drops a neo4j constraint on a property
|
42
42
|
# See http://docs.neo4j.org/chunked/stable/query-constraints.html
|
43
43
|
# @example
|
44
|
-
# label =
|
44
|
+
# label = ActiveGraph::Label.create(:person, driver)
|
45
45
|
# label.create_constraint(:name, {type: :unique}, driver)
|
46
46
|
# label.drop_constraint(:name, {type: :unique}, driver)
|
47
47
|
#
|
@@ -76,7 +76,7 @@ module Neo4j
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def constraints(_options = {})
|
79
|
-
|
79
|
+
ActiveGraph::Transaction.constraints.select do |definition|
|
80
80
|
definition[:label] == @name.to_sym
|
81
81
|
end
|
82
82
|
end
|
@@ -109,13 +109,13 @@ module Neo4j
|
|
109
109
|
|
110
110
|
class << self
|
111
111
|
def indexes
|
112
|
-
|
112
|
+
ActiveGraph::Transaction.indexes
|
113
113
|
end
|
114
114
|
|
115
115
|
def drop_indexes
|
116
116
|
indexes.each do |definition|
|
117
117
|
begin
|
118
|
-
|
118
|
+
ActiveGraph::Transaction.query("DROP INDEX ON :`#{definition[:label]}`(#{definition[:properties][0]})")
|
119
119
|
rescue Neo4j::Driver::Exceptions::DatabaseException
|
120
120
|
# This will error on each constraint. Ignore and continue.
|
121
121
|
next
|
@@ -124,11 +124,11 @@ module Neo4j
|
|
124
124
|
end
|
125
125
|
|
126
126
|
def drop_constraints
|
127
|
-
|
128
|
-
|
127
|
+
ActiveGraph::Transaction.named_constraints.each do |constraint|
|
128
|
+
ActiveGraph::Transaction.query("DROP CONSTRAINT #{constraint.name}")
|
129
129
|
end
|
130
|
-
|
131
|
-
|
130
|
+
ActiveGraph::Transaction.constraints.each do |definition|
|
131
|
+
ActiveGraph::Transaction.query("DROP CONSTRAINT ON (n:`#{definition[:label]}`) ASSERT n.`#{definition[:properties][0]}` IS UNIQUE")
|
132
132
|
end
|
133
133
|
end
|
134
134
|
|
@@ -138,16 +138,16 @@ module Neo4j
|
|
138
138
|
end
|
139
139
|
|
140
140
|
def schema_threads
|
141
|
-
|
141
|
+
ActiveGraph::Transaction.instance_variable_get('@_schema_threads') || []
|
142
142
|
end
|
143
143
|
|
144
144
|
def set_schema_threads(array)
|
145
|
-
|
145
|
+
ActiveGraph::Transaction.instance_variable_set('@_schema_threads', array)
|
146
146
|
end
|
147
147
|
end
|
148
148
|
|
149
149
|
def schema_query(cypher)
|
150
|
-
|
150
|
+
ActiveGraph::Transaction.transaction { |tx| tx.query(cypher, {}) }
|
151
151
|
end
|
152
152
|
|
153
153
|
def validate_index_options!(options)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copied largely from activerecord/lib/active_record/log_subscriber.rb
|
2
|
-
module
|
2
|
+
module ActiveGraph
|
3
3
|
module Core
|
4
4
|
module Logging
|
5
5
|
class << self
|
@@ -30,7 +30,7 @@ module Neo4j
|
|
30
30
|
def neo4j_gem_path
|
31
31
|
return if !defined?(::Rails.root)
|
32
32
|
|
33
|
-
@neo4j_gem_path ||= File.expand_path('../../..',
|
33
|
+
@neo4j_gem_path ||= File.expand_path('../../..', ActiveGraph::Base.method(:current_driver).source_location[0])
|
34
34
|
end
|
35
35
|
|
36
36
|
def active_support_gem_path
|
@@ -1,9 +1,9 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
3
|
-
require '
|
4
|
-
require '
|
1
|
+
require 'active_graph/core/instrumentable'
|
2
|
+
require 'active_graph/transaction'
|
3
|
+
require 'active_graph/core/query_builder'
|
4
|
+
require 'active_graph/core/responses'
|
5
5
|
|
6
|
-
module
|
6
|
+
module ActiveGraph
|
7
7
|
module Core
|
8
8
|
module Querable
|
9
9
|
extend ActiveSupport::Concern
|
@@ -16,7 +16,7 @@ module Neo4j
|
|
16
16
|
when 3
|
17
17
|
args.pop
|
18
18
|
when 2
|
19
|
-
args.pop if args[0].is_a?(::
|
19
|
+
args.pop if args[0].is_a?(::ActiveGraph::Core::Query)
|
20
20
|
end || {}
|
21
21
|
|
22
22
|
queries(options) { append(*args) }[0]
|
@@ -69,7 +69,7 @@ module Neo4j
|
|
69
69
|
result_from_data(transaction.root_tx.run(query.cypher, query.parameters))
|
70
70
|
end
|
71
71
|
rescue Neo4j::Driver::Exceptions::Neo4jException => e
|
72
|
-
raise
|
72
|
+
raise ActiveGraph::Core::CypherError.new_from(e.code, e.message) # , e.stack_track.to_a
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
1
|
+
require 'active_graph/core/query_clauses'
|
2
|
+
require 'active_graph/core/query_find_in_batches'
|
3
3
|
require 'active_support/notifications'
|
4
4
|
|
5
|
-
module
|
5
|
+
module ActiveGraph
|
6
6
|
module Core
|
7
7
|
# Allows for generation of cypher queries via ruby method calls (inspired by ActiveRecord / arel syntax)
|
8
8
|
#
|
@@ -13,8 +13,8 @@ module Neo4j
|
|
13
13
|
# See also the following link for full cypher language documentation:
|
14
14
|
# http://docs.neo4j.org/chunked/milestone/cypher-query-lang.html
|
15
15
|
class Query
|
16
|
-
include
|
17
|
-
include
|
16
|
+
include ActiveGraph::Core::QueryClauses
|
17
|
+
include ActiveGraph::Core::QueryFindInBatches
|
18
18
|
DEFINED_CLAUSES = {}
|
19
19
|
|
20
20
|
|
@@ -237,7 +237,7 @@ module Neo4j
|
|
237
237
|
def response
|
238
238
|
return @response if @response
|
239
239
|
|
240
|
-
@response =
|
240
|
+
@response = ActiveGraph::Transaction.query(self, transaction: Transaction.root, wrap_level: (:core_entity if unwrapped?))
|
241
241
|
end
|
242
242
|
|
243
243
|
def raise_if_cypher_error!(response)
|
@@ -271,12 +271,12 @@ module Neo4j
|
|
271
271
|
# @method to_a
|
272
272
|
# Class is Enumerable. Each yield is a Hash with the key matching the variable returned and the value being the value for that key from the response
|
273
273
|
# @return [Array]
|
274
|
-
# @raise [
|
274
|
+
# @raise [ActiveGraph::Server::CypherResponse::ResponseError] Raises errors from neo4j server
|
275
275
|
|
276
276
|
|
277
277
|
# Executes a query without returning the result
|
278
278
|
# @return [Boolean] true if successful
|
279
|
-
# @raise [
|
279
|
+
# @raise [ActiveGraph::Server::CypherResponse::ResponseError] Raises errors from neo4j server
|
280
280
|
def exec
|
281
281
|
response
|
282
282
|
|
@@ -363,8 +363,8 @@ module Neo4j
|
|
363
363
|
#
|
364
364
|
# @example
|
365
365
|
# # Generates cypher: MATCH (n:Person) UNION MATCH (o:Person) WHERE o.age = 10
|
366
|
-
# q =
|
367
|
-
# result =
|
366
|
+
# q = ActiveGraph::Core::Query.new.match(o: :Person).where(o: {age: 10})
|
367
|
+
# result = ActiveGraph::Core::Query.new.match(n: :Person).union_cypher(q)
|
368
368
|
#
|
369
369
|
# @param other [Query] Second half of UNION
|
370
370
|
# @param options [Hash] Specify {all: true} to use UNION ALL
|
@@ -439,7 +439,7 @@ module Neo4j
|
|
439
439
|
second_to_last << clause
|
440
440
|
elsif clause_is_with_following_order_or_limit?(clause)
|
441
441
|
second_to_last << clause
|
442
|
-
second_to_last.sort_by! { |c| c.is_a?(::
|
442
|
+
second_to_last.sort_by! { |c| c.is_a?(::ActiveGraph::Core::QueryClauses::OrderClause) ? 1 : 0 }
|
443
443
|
else
|
444
444
|
@partitioning.last << clause
|
445
445
|
end
|
@@ -460,19 +460,19 @@ module Neo4j
|
|
460
460
|
self.class.clause_is_order_or_limit?(clause) &&
|
461
461
|
@partitioning[-2] &&
|
462
462
|
@partitioning[-1].empty? &&
|
463
|
-
(@partitioning[-2].last.is_a?(::
|
464
|
-
@partitioning[-2].last.is_a?(::
|
463
|
+
(@partitioning[-2].last.is_a?(::ActiveGraph::Core::QueryClauses::WithClause) ||
|
464
|
+
@partitioning[-2].last.is_a?(::ActiveGraph::Core::QueryClauses::OrderClause))
|
465
465
|
end
|
466
466
|
|
467
467
|
def clause_is_with_following_order_or_limit?(clause)
|
468
|
-
clause.is_a?(::
|
468
|
+
clause.is_a?(::ActiveGraph::Core::QueryClauses::WithClause) &&
|
469
469
|
@partitioning[-2] && @partitioning[-2].any? { |c| self.class.clause_is_order_or_limit?(c) }
|
470
470
|
end
|
471
471
|
|
472
472
|
class << self
|
473
473
|
def clause_is_order_or_limit?(clause)
|
474
|
-
clause.is_a?(::
|
475
|
-
clause.is_a?(::
|
474
|
+
clause.is_a?(::ActiveGraph::Core::QueryClauses::OrderClause) ||
|
475
|
+
clause.is_a?(::ActiveGraph::Core::QueryClauses::LimitClause)
|
476
476
|
end
|
477
477
|
end
|
478
478
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module ActiveGraph
|
2
2
|
module Core
|
3
3
|
class QueryBuilder
|
4
4
|
attr_reader :queries
|
@@ -13,7 +13,7 @@ module Neo4j
|
|
13
13
|
query = case args.map(&:class)
|
14
14
|
when [String], [String, Hash]
|
15
15
|
Query.new(args[0], args[1] || {})
|
16
|
-
when [::
|
16
|
+
when [::ActiveGraph::Core::Query]
|
17
17
|
args[0]
|
18
18
|
else
|
19
19
|
fail ArgumentError, "Could not determine query from arguments: #{args.inspect}"
|
@@ -25,7 +25,7 @@ module Neo4j
|
|
25
25
|
def query
|
26
26
|
# `nil` drivers are just a workaround until
|
27
27
|
# we phase out `Query` objects containing drivers
|
28
|
-
|
28
|
+
ActiveGraph::Core::Query.new(driver: nil)
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -1,15 +1,15 @@
|
|
1
|
-
module
|
1
|
+
module ActiveGraph
|
2
2
|
module Core
|
3
3
|
class Query
|
4
|
-
# Creates a
|
4
|
+
# Creates a ActiveGraph::Node::Query::QueryProxy object that builds off of a Core::Query object.
|
5
5
|
#
|
6
|
-
# @param [Class] model An
|
6
|
+
# @param [Class] model An Node model to be used as the start of a new QueryuProxy chain
|
7
7
|
# @param [Symbol] var The variable to be used to refer to the object from within the new QueryProxy
|
8
8
|
# @param [Boolean] optional Indicate whether the new QueryProxy will use MATCH or OPTIONAL MATCH.
|
9
|
-
# @return [
|
9
|
+
# @return [ActiveGraph::Node::Query::QueryProxy] A QueryProxy object.
|
10
10
|
def proxy_as(model, var, optional = false)
|
11
11
|
# TODO: Discuss whether it's necessary to call `break` on the query or if this should be left to the user.
|
12
|
-
|
12
|
+
ActiveGraph::Node::Query::QueryProxy.new(model, nil, node: var, optional: optional, starting_query: self, chain_level: @proxy_chain_level)
|
13
13
|
end
|
14
14
|
|
15
15
|
# Calls proxy_as with `optional` set true. This doesn't offer anything different from calling `proxy_as` directly but it may be more readable.
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module ActiveGraph
|
2
2
|
module Core
|
3
3
|
module QueryFindInBatches
|
4
4
|
def find_in_batches(node_var, prop_var, options = {})
|
@@ -18,7 +18,7 @@ module Neo4j
|
|
18
18
|
|
19
19
|
break if records_size < batch_size
|
20
20
|
|
21
|
-
primary_key_var =
|
21
|
+
primary_key_var = ActiveGraph::Core::QueryClauses::Clause.from_key_and_single_value(node_var, prop_var)
|
22
22
|
records = query.where("#{primary_key_var} > $primary_key_offset")
|
23
23
|
.params(primary_key_offset: primary_key_offset).to_a
|
24
24
|
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require '
|
1
|
+
require 'active_graph/core/result'
|
2
2
|
require 'active_support/core_ext/module/attribute_accessors'
|
3
3
|
|
4
|
-
module
|
4
|
+
module ActiveGraph
|
5
5
|
module Core
|
6
6
|
module Responses
|
7
7
|
extend ActiveSupport::Concern
|
@@ -16,7 +16,7 @@ module Neo4j
|
|
16
16
|
wrap(entity_data.values)
|
17
17
|
end
|
18
18
|
|
19
|
-
|
19
|
+
ActiveGraph::Core::Result.new(entities_data.keys, rows)
|
20
20
|
end
|
21
21
|
|
22
22
|
private
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'benchmark'
|
2
|
-
require '
|
2
|
+
require 'active_graph/migrations/helpers/id_property'
|
3
3
|
|
4
|
-
module
|
4
|
+
module ActiveGraph
|
5
5
|
class Migration
|
6
6
|
def migrate
|
7
7
|
fail 'not implemented'
|
@@ -28,11 +28,11 @@ module Neo4j
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def query(*args)
|
31
|
-
|
31
|
+
ActiveGraph::Base.current_driver.query(*args)
|
32
32
|
end
|
33
33
|
|
34
|
-
class AddIdProperty <
|
35
|
-
include
|
34
|
+
class AddIdProperty < ActiveGraph::Migration
|
35
|
+
include ActiveGraph::Migrations::Helpers::IdProperty
|
36
36
|
|
37
37
|
attr_reader :models_filename
|
38
38
|
|
@@ -55,11 +55,11 @@ module Neo4j
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def query(*args)
|
58
|
-
|
58
|
+
Base.magic_query(*args)
|
59
59
|
end
|
60
60
|
|
61
61
|
def execute(*args)
|
62
|
-
|
62
|
+
Base.query(*args)
|
63
63
|
end
|
64
64
|
|
65
65
|
def setup
|
@@ -96,7 +96,7 @@ MESSAGE
|
|
96
96
|
# end
|
97
97
|
|
98
98
|
# def idless_count(label, id_property)
|
99
|
-
#
|
99
|
+
# ActiveGraph::Base.new_query.match(n: label).where("NOT EXISTS(n.#{id_property})").pluck('COUNT(n) AS ids').first
|
100
100
|
# end
|
101
101
|
|
102
102
|
# def print_status(last_time_taken, max_per_batch, nodes_left)
|
@@ -113,9 +113,9 @@ MESSAGE
|
|
113
113
|
|
114
114
|
|
115
115
|
# def id_batch_set(label, id_property, new_ids, count)
|
116
|
-
# tx =
|
116
|
+
# tx = ActiveGraph::Base.new_transaction
|
117
117
|
|
118
|
-
#
|
118
|
+
# ActiveGraph::Base.current_driver.query("MATCH (n:`#{label}`) WHERE NOT EXISTS(n.#{id_property})
|
119
119
|
# with COLLECT(n) as nodes, #{new_ids} as ids
|
120
120
|
# FOREACH(i in range(0,#{count - 1})|
|
121
121
|
# FOREACH(node in [nodes[i]]|
|
@@ -124,7 +124,7 @@ MESSAGE
|
|
124
124
|
# LIMIT #{count}")
|
125
125
|
|
126
126
|
# count
|
127
|
-
# rescue
|
127
|
+
# rescue ActiveGraph::Server::CypherResponse::ResponseError, Faraday::TimeoutError
|
128
128
|
# new_max_per_batch = (max_per_batch * 0.8).round
|
129
129
|
# output "Error querying #{max_per_batch} nodes. Trying #{new_max_per_batch}"
|
130
130
|
# new_max_per_batch
|