neo4j 9.3.0 → 9.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: bad07009eb162540cc513015fd204759147c4dbc
4
- data.tar.gz: e4922271304dbd7a9b03a1fe5afed9b252056e4d
2
+ SHA256:
3
+ metadata.gz: ddd749f4da3296fd19bb4c39c1981e3b612d58715fcfbc7bf4e7267811284312
4
+ data.tar.gz: a39833454052a0fee01b2fbcc781d4334521a1f32415e410e711daa1867eeff0
5
5
  SHA512:
6
- metadata.gz: cbfe650533ccccf0d12d5afc37b6762f860ba90b64ec3d552867df198db6dc31524ce987bc40e7869e4bf333aa90ec3b674322cf03bc54676594708901160da2
7
- data.tar.gz: 78b8a4a89affb828af5f27c46826710d51d43dc6789778eb793dd4cfe80b4b10beff46d7b89eb03337bf2b6811f6dd551027f4927ba25406796a99bd4b35b057
6
+ metadata.gz: bb6c4d92ca9cf8544e33da06b29568e44f24ba8f87a5a861256a1cdb369acf536467ccbaafcd102b7ad04457c9da69149c0e0cec92c290b85869ef55063318ff
7
+ data.tar.gz: 3ee2eaf941aa6e406d7a764c843dbd2b51502452d2682512bb6c512077003c9a9f5021b905332fc7a8bb1480fa80fce49e82b055f60f058345474d9f9d67ce40
@@ -3,6 +3,20 @@ 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
+ ## [9.4.0] 2018-12-20
7
+
8
+ ## Added
9
+
10
+ - `verbose_query_logs` configuration option to allow outputting of source location of queries
11
+ - Adaptor classes loaded dynamically on demand
12
+ - Optionally specify the full adaptor class name instead of session type only (supports driver adaptor)
13
+
14
+ ## Fixed
15
+
16
+ - Wrong conflicting node aliases on same `branch` usage (see #1526)
17
+ - Incorrect order when `order` and `with_associations` are used together
18
+ - `ScopeEvalContext` redirects now all method missing calls to QueryProxy or Target
19
+
6
20
  ## [9.3.0] 2018-07-12
7
21
 
8
22
  ## Added
@@ -1,8 +1,7 @@
1
1
  require 'neo4j/version'
2
2
 
3
3
  require 'neo4j-core'
4
- require 'neo4j/core/cypher_session'
5
- require 'neo4j/core/query'
4
+ require 'neo4j/core/query_ext' # From this gem
6
5
 
7
6
  require 'neo4j/active_base'
8
7
  require 'neo4j/model_schema'
@@ -17,7 +17,7 @@ module Neo4j::ActiveNode
17
17
  end
18
18
 
19
19
  def define_enum_scopes(property_name, enum_keys)
20
- enum_keys.keys.each do |name|
20
+ enum_keys.each_key do |name|
21
21
  scope name, -> { where(property_name => name) }
22
22
  end
23
23
  end
@@ -239,7 +239,7 @@ module Neo4j::ActiveNode
239
239
  query_proxy = self.class.as(:previous).where(neo_id: result_cache.map(&:neo_id))
240
240
  query_proxy = self.class.send(:association_query_proxy, association_name, previous_query_proxy: query_proxy, node: :next, optional: true)
241
241
 
242
- Hash[*query_proxy.pluck('ID(previous)', 'collect(next)').flatten(1)].each do |_, records|
242
+ Hash[*query_proxy.pluck('ID(previous)', 'collect(next)').flatten(1)].each_value do |records|
243
243
  records.each do |record|
244
244
  record.instance_variable_set('@source_proxy_result_cache', records)
245
245
  end
@@ -248,8 +248,7 @@ module Neo4j::ActiveNode
248
248
 
249
249
  # rubocop:disable Metrics/ModuleLength
250
250
  module ClassMethods
251
- # rubocop:enable Style/PredicateName
252
- # rubocop:disable Style/PredicateName
251
+ # rubocop:disable Naming/PredicateName
253
252
 
254
253
  # :nocov:
255
254
  def has_association?(name)
@@ -259,7 +258,7 @@ module Neo4j::ActiveNode
259
258
  end
260
259
  # :nocov:
261
260
 
262
- # rubocop:enable Style/PredicateName
261
+ # rubocop:enable Naming/PredicateName
263
262
 
264
263
  def association?(name)
265
264
  !!associations[name.to_sym]
@@ -360,7 +359,7 @@ module Neo4j::ActiveNode
360
359
  # **Available values:** ``:delete``, ``:delete_orphans``, ``:destroy``, ``:destroy_orphans``
361
360
  # (note that the ``:destroy_orphans`` option is known to be "very metal". Caution advised)
362
361
  #
363
- def has_many(direction, name, options = {}) # rubocop:disable Style/PredicateName
362
+ def has_many(direction, name, options = {}) # rubocop:disable Naming/PredicateName
364
363
  name = name.to_sym
365
364
  build_association(:has_many, direction, name, options)
366
365
 
@@ -377,7 +376,7 @@ module Neo4j::ActiveNode
377
376
  # See :ref:`#has_many <Neo4j/ActiveNode/HasN/ClassMethods#has_many>` for anything
378
377
  # not specified here
379
378
  #
380
- def has_one(direction, name, options = {}) # rubocop:disable Style/PredicateName
379
+ def has_one(direction, name, options = {}) # rubocop:disable Naming/PredicateName
381
380
  name = name.to_sym
382
381
  build_association(:has_one, direction, name, options)
383
382
 
@@ -578,5 +577,6 @@ module Neo4j::ActiveNode
578
577
  associations.key?(name) && parent_associations[name] != associations[name]
579
578
  end
580
579
  end
580
+ # rubocop:enable Metrics/ModuleLength
581
581
  end
582
582
  end
@@ -145,13 +145,13 @@ module Neo4j::ActiveNode
145
145
  TypeMethods.define_id_methods(self, name, conf)
146
146
  end
147
147
 
148
- # rubocop:disable Style/PredicateName
148
+ # rubocop:disable Naming/PredicateName
149
149
  def has_id_property?
150
150
  ActiveSupport::Deprecation.warn 'has_id_property? is deprecated and may be removed from future releases, use id_property? instead.', caller
151
151
 
152
152
  id_property?
153
153
  end
154
- # rubocop:enable Style/PredicateName
154
+ # rubocop:enable Naming/PredicateName
155
155
 
156
156
  def id_property?
157
157
  id_property_info && !id_property_info.empty?
@@ -209,7 +209,7 @@ MSG
209
209
  end
210
210
 
211
211
  def id_property_name_type_value
212
- name, type, value = Neo4j::Config.to_hash.values_at(*%w(id_property id_property_type id_property_type_value))
212
+ name, type, value = Neo4j::Config.to_hash.values_at('id_property', 'id_property_type', 'id_property_type_value')
213
213
 
214
214
  unless name == :neo_id || (name && type && value)
215
215
  name = :uuid
@@ -166,13 +166,13 @@ module Neo4j
166
166
  @mapped_label_name = name.to_sym
167
167
  end
168
168
 
169
- # rubocop:disable Style/AccessorMethodName
169
+ # rubocop:disable Naming/AccessorMethodName
170
170
  def set_mapped_label_name(name)
171
171
  ActiveSupport::Deprecation.warn 'set_mapped_label_name is deprecated, use self.mapped_label_name= instead.', caller
172
172
 
173
173
  self.mapped_label_name = name
174
174
  end
175
- # rubocop:enable Style/AccessorMethodName
175
+ # rubocop:enable Naming/AccessorMethodName
176
176
 
177
177
  private
178
178
 
@@ -66,7 +66,7 @@ module Neo4j
66
66
  # in the QueryProxy chain.
67
67
  attr_reader :node_var
68
68
  def identity
69
- @node_var || _result_string
69
+ @node_var || _result_string(_chain_level + 1)
70
70
  end
71
71
  alias node_identity identity
72
72
 
@@ -309,11 +309,8 @@ module Neo4j
309
309
  Neo4j::ActiveBase.new_query(context: @context)
310
310
  end
311
311
 
312
- # TODO: Refactor this. Too much happening here.
313
- def _result_string
314
- s = (self.association && self.association.name) || (self.model && self.model.name) || ''
315
-
316
- s ? "result_#{s}".downcase.tr(':', '').to_sym : :result
312
+ def _result_string(index = nil)
313
+ "result_#{(association || model).try(:name)}#{index}".downcase.tr(':', '').to_sym
317
314
  end
318
315
 
319
316
  def _session
@@ -31,9 +31,9 @@ module Neo4j
31
31
  if spec.is_a?(Array)
32
32
  spec.each { |s| add_spec(s) }
33
33
  elsif spec.is_a?(Hash)
34
- spec.each { |k, v| (self[k] ||= AssociationTree.new(model, k)).add_spec(v) }
34
+ process_hash(spec)
35
35
  else
36
- self[spec] ||= AssociationTree.new(model, spec)
36
+ self[spec] ||= self.class.new(model, spec)
37
37
  end
38
38
  end
39
39
 
@@ -41,6 +41,10 @@ module Neo4j
41
41
  values.flat_map { |v| [[*prefix, v]] + v.paths(*prefix, v) }
42
42
  end
43
43
 
44
+ def process_hash(spec)
45
+ spec.each { |k, v| (self[k] ||= self.class.new(model, k)).add_spec(v) }
46
+ end
47
+
44
48
  private
45
49
 
46
50
  def target_class(model, key)
@@ -56,7 +60,7 @@ module Neo4j
56
60
 
57
61
  def perform_query
58
62
  @_cache = IdentityMap.new
59
- query_from_association_tree
63
+ build_query
60
64
  .map do |record, eager_data|
61
65
  cache_and_init(record, with_associations_tree)
62
66
  eager_data.zip(with_associations_tree.paths.map(&:last)).each do |eager_records, element|
@@ -82,7 +86,11 @@ module Neo4j
82
86
  end
83
87
 
84
88
  def with_associations_tree
85
- @with_associations_tree ||= AssociationTree.new(model)
89
+ @with_associations_tree ||= association_tree_class.new(model)
90
+ end
91
+
92
+ def association_tree_class
93
+ AssociationTree
86
94
  end
87
95
 
88
96
  def with_associations_tree=(tree)
@@ -106,19 +114,19 @@ module Neo4j
106
114
  end
107
115
 
108
116
  def init_associations(node, element)
109
- element.keys.each { |key| node.association_proxy(key).init_cache }
117
+ element.each_key { |key| node.association_proxy(key).init_cache }
110
118
  end
111
119
 
112
120
  def cache_and_init(node, element)
113
121
  @_cache.add(node).tap { |n| init_associations(n, element) }
114
122
  end
115
123
 
116
- def with_associations_return_clause(variables = path_names)
117
- var_list(variables, &:itself)
124
+ def with_associations_return_clause
125
+ path_names.map { |n| var(n, :collection, &:itself) }.join(',')
118
126
  end
119
127
 
120
- def var_list(variables)
121
- variables.map { |n| yield(escape("#{n}_collection")) }.join(',')
128
+ def var(*parts)
129
+ yield(escape(parts.compact.join('_')))
122
130
  end
123
131
 
124
132
  # In neo4j version 2.1.8 this fails due to a bug:
@@ -128,8 +136,12 @@ module Neo4j
128
136
  # and this
129
137
  # MATCH (`n`) WITH `n` AS `n` RETURN `n`
130
138
  # does not
131
- def var_list_fixing_neo4j_2_1_8_bug(variables)
132
- var_list(variables) { |var| "#{var} AS #{var}" }
139
+ def var_fix(*var)
140
+ var(*var, &method(:as_alias))
141
+ end
142
+
143
+ def as_alias(var)
144
+ "#{var} AS #{var}"
133
145
  end
134
146
 
135
147
  def escape(s)
@@ -144,25 +156,31 @@ module Neo4j
144
156
  with_associations_tree.paths.map { |path| path_name(path) }
145
157
  end
146
158
 
159
+ def build_query
160
+ before_pluck(query_from_association_tree).pluck(identity, "[#{with_associations_return_clause}]")
161
+ end
162
+
163
+ def before_pluck(query)
164
+ query_from_chain(@order_chain, query, identity)
165
+ end
166
+
147
167
  def query_from_association_tree
148
- previous_with_variables = []
149
- no_order_query = with_associations_tree.paths.inject(query_as(identity).with(ensure_distinct(identity))) do |query, path|
150
- with_association_query_part(query, path, previous_with_variables).tap do
151
- previous_with_variables << path_name(path)
168
+ previous_with_vars = []
169
+ with_associations_tree.paths.inject(query_as(identity).with(ensure_distinct(identity))) do |query, path|
170
+ with_association_query_part(query, path, previous_with_vars).tap do
171
+ previous_with_vars << var_fix(path_name(path), :collection)
152
172
  end
153
173
  end
154
- query_from_chain(@order_chain, no_order_query, identity)
155
- .pluck(identity, "[#{with_associations_return_clause}]")
156
174
  end
157
175
 
158
- def with_association_query_part(base_query, path, previous_with_variables)
159
- optional_match_with_where(base_query, path)
176
+ def with_association_query_part(base_query, path, previous_with_vars)
177
+ optional_match_with_where(base_query, path, previous_with_vars)
160
178
  .with(identity,
161
179
  "[collect(#{escape("#{path_name(path)}_rel")}), collect(#{escape path_name(path)})] AS #{escape("#{path_name(path)}_collection")}",
162
- *var_list_fixing_neo4j_2_1_8_bug(previous_with_variables))
180
+ *previous_with_vars)
163
181
  end
164
182
 
165
- def optional_match_with_where(base_query, path)
183
+ def optional_match_with_where(base_query, path, _)
166
184
  path
167
185
  .each_with_index.map { |_, index| path[0..index] }
168
186
  .inject(optional_match(base_query, path)) do |query, path_prefix|
@@ -183,9 +201,8 @@ module Neo4j
183
201
  end
184
202
 
185
203
  def chain
186
- @order_chain, other_chain =
187
- with_associations_tree.empty? ? [[], @chain] : @chain.partition { |link| link.clause == :order }
188
- other_chain
204
+ @order_chain = @chain.select { |link| link.clause == :order } unless with_associations_tree.empty?
205
+ @chain
189
206
  end
190
207
  end
191
208
  end
@@ -51,13 +51,13 @@ module Neo4j::ActiveNode
51
51
  end
52
52
  end
53
53
 
54
- # rubocop:disable Style/PredicateName
54
+ # rubocop:disable Naming/PredicateName
55
55
  def has_scope?(name)
56
56
  ActiveSupport::Deprecation.warn 'has_scope? is deprecated and may be removed from future releases, use scope? instead.', caller
57
57
 
58
58
  scope?(name)
59
59
  end
60
- # rubocop:enable Style/PredicateName
60
+ # rubocop:enable Naming/PredicateName
61
61
 
62
62
  # @return [Boolean] true if model has access to scope with this name
63
63
  def scope?(name)
@@ -116,13 +116,12 @@ module Neo4j::ActiveNode
116
116
  end
117
117
  end
118
118
 
119
+ # method_missing is not delegated to super class but to aggregated class
120
+ # rubocop:disable Style/MethodMissingSuper
119
121
  def method_missing(name, *params, &block)
120
- if query_proxy_or_target.respond_to?(name)
121
- query_proxy_or_target.public_send(name, *params, &block)
122
- else
123
- super
124
- end
122
+ query_proxy_or_target.public_send(name, *params, &block)
125
123
  end
124
+ # rubocop:enable Style/MethodMissingSuper
126
125
 
127
126
  private
128
127
 
@@ -70,6 +70,10 @@ module Neo4j
70
70
  configuration[key.to_s]
71
71
  end
72
72
 
73
+ def fetch(key, default)
74
+ configuration.fetch(key, default)
75
+ end
76
+
73
77
  # Remove the value of a config entry.
74
78
  #
75
79
  # @param [Symbol] key the key of the configuration entry to delete
@@ -0,0 +1,24 @@
1
+ module Neo4j
2
+ module Core
3
+ class Query
4
+ # Creates a Neo4j::ActiveNode::Query::QueryProxy object that builds off of a Core::Query object.
5
+ #
6
+ # @param [Class] model An ActiveNode model to be used as the start of a new QueryuProxy chain
7
+ # @param [Symbol] var The variable to be used to refer to the object from within the new QueryProxy
8
+ # @param [Boolean] optional Indicate whether the new QueryProxy will use MATCH or OPTIONAL MATCH.
9
+ # @return [Neo4j::ActiveNode::Query::QueryProxy] A QueryProxy object.
10
+ def proxy_as(model, var, optional = false)
11
+ # TODO: Discuss whether it's necessary to call `break` on the query or if this should be left to the user.
12
+ Neo4j::ActiveNode::Query::QueryProxy.new(model, nil, node: var, optional: optional, starting_query: self, chain_level: @proxy_chain_level)
13
+ end
14
+
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.
16
+ def proxy_as_optional(model, var)
17
+ proxy_as(model, var, true)
18
+ end
19
+
20
+ # For instances where you turn a QueryProxy into a Query and then back to a QueryProxy with `#proxy_as`
21
+ attr_accessor :proxy_chain_level
22
+ end
23
+ end
24
+ end
@@ -27,7 +27,9 @@ module Neo4j
27
27
  FileUtils.mkdir_p('db/neo4j-migrate')
28
28
  end
29
29
 
30
- delegate :query, to: Neo4j::Session
30
+ def query(*args)
31
+ Neo4j::ActiveBase.current_session.query(*args)
32
+ end
31
33
 
32
34
  class AddIdProperty < Neo4j::Migration
33
35
  include Neo4j::Migrations::Helpers::IdProperty
@@ -3,9 +3,7 @@ require 'rails/railtie'
3
3
  require 'neo4j/session_manager'
4
4
  # Need the action_dispatch railtie to have action_dispatch.rescue_responses initialized correctly
5
5
  require 'action_dispatch/railtie'
6
- require 'neo4j/core/cypher_session/adaptors/http'
7
- require 'neo4j/core/cypher_session/adaptors/bolt'
8
- require 'neo4j/core/cypher_session/adaptors/embedded'
6
+ require 'neo4j/core/cypher_session/adaptors'
9
7
 
10
8
  module Neo4j
11
9
  class Railtie < ::Rails::Railtie
@@ -38,6 +36,7 @@ module Neo4j
38
36
 
39
37
  console do
40
38
  Neo4j::Config[:logger] = ActiveSupport::Logger.new(STDOUT)
39
+ Neo4j::Config[:verbose_query_logs] = false
41
40
  end
42
41
 
43
42
  # Starting Neo after :load_config_initializers allows apps to
@@ -62,18 +61,22 @@ module Neo4j
62
61
  def setup!(neo4j_config = empty_config)
63
62
  wait_for_connection = neo4j_config.wait_for_connection
64
63
  type, url, path, options = final_session_config!(neo4j_config).values_at(:type, :url, :path, :options)
65
- register_neo4j_cypher_logging(type || default_session_type)
64
+ type ||= default_session_type
65
+ options ||= {}
66
+ register_neo4j_cypher_logging(type, options)
66
67
 
67
- Neo4j::SessionManager.open_neo4j_session(type || default_session_type,
68
+ Neo4j::SessionManager.open_neo4j_session(type,
68
69
  url || path || default_session_path_or_url,
69
70
  wait_for_connection,
70
- options || {})
71
+ options)
71
72
  end
72
73
 
73
74
  def final_session_config!(neo4j_config)
74
75
  support_deprecated_session_configs!(neo4j_config)
75
76
 
76
- neo4j_config[:session].empty? ? yaml_config_data : neo4j_config[:session]
77
+ (neo4j_config[:session].empty? ? yaml_config_data : neo4j_config[:session]).dup.tap do |result|
78
+ result[:type] ||= URI(result[:url]).scheme if result[:url]
79
+ end
77
80
  end
78
81
 
79
82
  def support_deprecated_session_configs!(neo4j_config)
@@ -120,7 +123,7 @@ module Neo4j
120
123
  end.detect(&:exist?)
121
124
  end
122
125
 
123
- def register_neo4j_cypher_logging(session_type)
126
+ def register_neo4j_cypher_logging(session_type, options)
124
127
  return if @neo4j_cypher_logging_registered
125
128
 
126
129
  Neo4j::Core::Query.pretty_cypher = Neo4j::Config[:pretty_logged_cypher_queries]
@@ -129,23 +132,18 @@ module Neo4j
129
132
  (Neo4j::Config[:logger] ||= Rails.logger).debug message
130
133
  end
131
134
  Neo4j::Core::CypherSession::Adaptors::Base.subscribe_to_query(&logger_proc)
132
- subscribe_to_session_type_logging!(session_type, logger_proc)
135
+ subscribe_to_session_type_logging!(session_type, options, logger_proc)
133
136
 
134
137
  @neo4j_cypher_logging_registered = true
135
138
  end
136
139
 
137
- TYPE_SUBSCRIBERS = {
138
- http: Neo4j::Core::CypherSession::Adaptors::HTTP.method(:subscribe_to_request),
139
- bolt: Neo4j::Core::CypherSession::Adaptors::Bolt.method(:subscribe_to_request),
140
- embedded: Neo4j::Core::CypherSession::Adaptors::Embedded.method(:subscribe_to_transaction)
141
- }
142
-
143
- def subscribe_to_session_type_logging!(session_type, logger_proc)
144
- if TYPE_SUBSCRIBERS.key?(session_type.to_sym)
145
- TYPE_SUBSCRIBERS[session_type.to_sym].call(&logger_proc)
146
- else
147
- fail ArgumentError, "Invalid session type: #{session_type.inspect} (expected one of #{TYPE_SUBSCRIBERS.keys.inspect})"
148
- end
140
+ def subscribe_to_session_type_logging!(session_type, options, logger_proc)
141
+ SessionManager
142
+ .adaptor_class(session_type, options)
143
+ .send(
144
+ [:embedded, :embedded_db].include?(session_type.to_sym) ? :subscribe_to_transaction : :subscribe_to_request,
145
+ &logger_proc
146
+ )
149
147
  end
150
148
  end
151
149
  end
@@ -1,8 +1,5 @@
1
1
  require 'active_support/core_ext/hash'
2
2
  require 'active_support/ordered_options'
3
- require 'neo4j/core/cypher_session/adaptors/http'
4
- require 'neo4j/core/cypher_session/adaptors/bolt'
5
- require 'neo4j/core/cypher_session/adaptors/embedded'
6
3
 
7
4
  module Neo4j
8
5
  class SessionManager
@@ -11,12 +8,18 @@ module Neo4j
11
8
  enable_unlimited_strength_crypto! if java_platform? && session_type_is_embedded?(type)
12
9
 
13
10
  adaptor = wait_for_value(wait_for_connection, Neo4j::Core::CypherSession::ConnectionFailedError) do
14
- cypher_session_adaptor(type, url_or_path, options.merge(wrap_level: :proc))
11
+ verbose_query_logs = Neo4j::Config.fetch(:verbose_query_logs, false)
12
+ cypher_session_adaptor(type, url_or_path, options.merge(wrap_level: :proc,
13
+ verbose_query_logs: verbose_query_logs))
15
14
  end
16
15
 
17
16
  Neo4j::Core::CypherSession.new(adaptor)
18
17
  end
19
18
 
19
+ def adaptor_class(type, options)
20
+ options[:adaptor_class] || adaptor_class_by_type(type.to_sym)
21
+ end
22
+
20
23
  protected
21
24
 
22
25
  def session_type_is_embedded?(session_type)
@@ -31,20 +34,8 @@ module Neo4j
31
34
  restricted_field.set nil, false
32
35
  end
33
36
 
34
- # TODO: Deprecate embedded_db and http in favor of embedded and http
35
- #
36
37
  def cypher_session_adaptor(type, path_or_url, options = {})
37
- case type.to_sym
38
- when :embedded_db, :embedded
39
- Neo4j::Core::CypherSession::Adaptors::Embedded.new(path_or_url, options)
40
- when :http
41
- Neo4j::Core::CypherSession::Adaptors::HTTP.new(path_or_url, options)
42
- when :bolt
43
- Neo4j::Core::CypherSession::Adaptors::Bolt.new(path_or_url, options)
44
- else
45
- extra = ' (`server_db` has been replaced by `http` or `bolt`)'
46
- fail ArgumentError, "Invalid session type: #{type.inspect}#{extra if type.to_sym == :server_db}"
47
- end
38
+ adaptor_class(type, options).new(path_or_url, options)
48
39
  end
49
40
 
50
41
  def java_platform?
@@ -69,6 +60,26 @@ module Neo4j
69
60
  end
70
61
  end
71
62
  end
63
+
64
+ private
65
+
66
+ def adaptor_class_by_type(type)
67
+ ActiveSupport::Deprecation.warn('`embedded_db` session type is deprecated, please use `embedded`') if type == :embedded_db
68
+ case type
69
+ when :embedded_db, :embedded
70
+ require 'neo4j/core/cypher_session/adaptors/embedded'
71
+ Neo4j::Core::CypherSession::Adaptors::Embedded
72
+ when :http
73
+ require 'neo4j/core/cypher_session/adaptors/http'
74
+ Neo4j::Core::CypherSession::Adaptors::HTTP
75
+ when :bolt
76
+ require 'neo4j/core/cypher_session/adaptors/bolt'
77
+ Neo4j::Core::CypherSession::Adaptors::Bolt
78
+ else
79
+ extra = ' (`server_db` has been replaced by `http` or `bolt`)'
80
+ fail ArgumentError, "Invalid session type: #{type.inspect} (expected one of [:http, :bolt, :embedded])#{extra if type == :server_db}"
81
+ end
82
+ end
72
83
  end
73
84
  end
74
85
  end
@@ -67,7 +67,7 @@ module Neo4j::Shared
67
67
  end
68
68
 
69
69
  unless case_sensitive
70
- enum_keys.keys.each do |key|
70
+ enum_keys.each_key do |key|
71
71
  fail ArgumentError, 'Enum keys must be lowercase unless _case_sensitive = true' unless key.downcase == key
72
72
  end
73
73
  end
@@ -130,7 +130,7 @@ module Neo4j::Shared
130
130
  end
131
131
 
132
132
  def define_enum_methods_?(property_name, enum_keys, options)
133
- enum_keys.keys.each do |enum_value|
133
+ enum_keys.each_key do |enum_value|
134
134
  method_name = build_method_name(enum_value, property_name, options)
135
135
  check_enum_method_conflicts! property_name, :"#{method_name}?"
136
136
  define_method("#{method_name}?") do
@@ -140,7 +140,7 @@ module Neo4j::Shared
140
140
  end
141
141
 
142
142
  def define_enum_methods_!(property_name, enum_keys, options)
143
- enum_keys.keys.each do |enum_value|
143
+ enum_keys.each_key do |enum_value|
144
144
  method_name = build_method_name(enum_value, property_name, options)
145
145
  check_enum_method_conflicts! property_name, :"#{method_name}!"
146
146
  define_method("#{method_name}!") do
@@ -44,7 +44,7 @@ module Neo4j::Shared
44
44
  # Not a good long term solution
45
45
  if changed_attributes.frozen?
46
46
  attributes_changed_by_setter = ActiveSupport::HashWithIndifferentAccess.new(changed_attributes)
47
- hash_to_clear.keys.each { |k| attributes_changed_by_setter.delete(k) }
47
+ hash_to_clear.each_key { |k| attributes_changed_by_setter.delete(k) }
48
48
  @attributes_changed_by_setter = attributes_changed_by_setter
49
49
  else
50
50
  hash_to_clear.each_key { |k| changed_attributes.delete(k) }
@@ -76,7 +76,7 @@ module Neo4j::Shared
76
76
  when respond_to?(:to_d)
77
77
  value.to_d
78
78
  else
79
- BigDecimal.new(value.to_s)
79
+ BigDecimal(value.to_s)
80
80
  end.to_s
81
81
  end
82
82
 
@@ -1,3 +1,4 @@
1
+ require 'rake'
1
2
  require 'active_support/concern'
2
3
  require 'neo4j/migration'
3
4
 
@@ -1,3 +1,3 @@
1
1
  module Neo4j
2
- VERSION = '9.3.0'
2
+ VERSION = '9.4.0'
3
3
  end
@@ -29,7 +29,7 @@ class Neo4j::Generators::ModelGenerator < Rails::Generators::NamedBase #:nodoc:
29
29
  options[:timestamps]
30
30
  end
31
31
 
32
- # rubocop:disable Style/PredicateName
32
+ # rubocop:disable Naming/PredicateName
33
33
  def has_many?
34
34
  options[:has_many]
35
35
  end
@@ -56,7 +56,7 @@ class Neo4j::Generators::ModelGenerator < Rails::Generators::NamedBase #:nodoc:
56
56
  end
57
57
  txt
58
58
  end
59
- # rubocop:enable Style/PredicateName
59
+ # rubocop:enable Naming/PredicateName
60
60
 
61
61
  def indices?
62
62
  options[:indices]
@@ -1,4 +1,4 @@
1
- lib = File.expand_path('../lib/', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
2
2
  $LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  require 'neo4j/version'
@@ -35,8 +35,9 @@ DESCRIPTION
35
35
 
36
36
  s.add_dependency('activemodel', '>= 4.0')
37
37
  s.add_dependency('activesupport', '>= 4.0')
38
+ s.add_dependency('i18n', '!= 1.3.0') # version 1.3.0 introduced a bug with `symbolize_key`
38
39
  s.add_dependency('neo4j-community', '~> 2.0') if RUBY_PLATFORM =~ /java/
39
- s.add_dependency('neo4j-core', '>= 7.2.2', '< 9.0.0')
40
+ s.add_dependency('neo4j-core', '>= 9.0.0')
40
41
  s.add_dependency('orm_adapter', '~> 0.5.0')
41
42
  s.add_development_dependency('guard')
42
43
  s.add_development_dependency('guard-rspec')
@@ -46,6 +47,6 @@ DESCRIPTION
46
47
  s.add_development_dependency('pry')
47
48
  s.add_development_dependency('railties', '>= 4.0')
48
49
  s.add_development_dependency('rake')
49
- s.add_development_dependency('rubocop', '~> 0.49.1')
50
+ s.add_development_dependency('rubocop', '~> 0.56.0')
50
51
  s.add_development_dependency('yard')
51
52
  end
metadata CHANGED
@@ -1,212 +1,234 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neo4j
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.3.0
4
+ version: 9.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andreas Ronge, Brian Underwood, Chris Grigg
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-12 00:00:00.000000000 Z
11
+ date: 2018-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: activemodel
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
16
  - - ">="
18
17
  - !ruby/object:Gem::Version
19
18
  version: '4.0'
20
- type: :runtime
19
+ name: activemodel
21
20
  prerelease: false
21
+ type: :runtime
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '4.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: activesupport
29
28
  requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
30
  - - ">="
32
31
  - !ruby/object:Gem::Version
33
32
  version: '4.0'
34
- type: :runtime
33
+ name: activesupport
35
34
  prerelease: false
35
+ type: :runtime
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '4.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: neo4j-core
43
42
  requirement: !ruby/object:Gem::Requirement
44
43
  requirements:
45
- - - ">="
44
+ - - "!="
46
45
  - !ruby/object:Gem::Version
47
- version: 7.2.2
48
- - - "<"
49
- - !ruby/object:Gem::Version
50
- version: 9.0.0
46
+ version: 1.3.0
47
+ name: i18n
48
+ prerelease: false
51
49
  type: :runtime
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "!="
53
+ - !ruby/object:Gem::Version
54
+ version: 1.3.0
55
+ - !ruby/object:Gem::Dependency
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '2.0'
61
+ name: neo4j-community
52
62
  prerelease: false
63
+ type: :runtime
53
64
  version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.0'
69
+ - !ruby/object:Gem::Dependency
70
+ requirement: !ruby/object:Gem::Requirement
54
71
  requirements:
55
72
  - - ">="
56
73
  - !ruby/object:Gem::Version
57
- version: 7.2.2
58
- - - "<"
74
+ version: 9.0.0
75
+ name: neo4j-core
76
+ prerelease: false
77
+ type: :runtime
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
59
81
  - !ruby/object:Gem::Version
60
82
  version: 9.0.0
61
83
  - !ruby/object:Gem::Dependency
62
- name: orm_adapter
63
84
  requirement: !ruby/object:Gem::Requirement
64
85
  requirements:
65
86
  - - "~>"
66
87
  - !ruby/object:Gem::Version
67
88
  version: 0.5.0
68
- type: :runtime
89
+ name: orm_adapter
69
90
  prerelease: false
91
+ type: :runtime
70
92
  version_requirements: !ruby/object:Gem::Requirement
71
93
  requirements:
72
94
  - - "~>"
73
95
  - !ruby/object:Gem::Version
74
96
  version: 0.5.0
75
97
  - !ruby/object:Gem::Dependency
76
- name: guard
77
98
  requirement: !ruby/object:Gem::Requirement
78
99
  requirements:
79
100
  - - ">="
80
101
  - !ruby/object:Gem::Version
81
102
  version: '0'
82
- type: :development
103
+ name: guard
83
104
  prerelease: false
105
+ type: :development
84
106
  version_requirements: !ruby/object:Gem::Requirement
85
107
  requirements:
86
108
  - - ">="
87
109
  - !ruby/object:Gem::Version
88
110
  version: '0'
89
111
  - !ruby/object:Gem::Dependency
90
- name: guard-rspec
91
112
  requirement: !ruby/object:Gem::Requirement
92
113
  requirements:
93
114
  - - ">="
94
115
  - !ruby/object:Gem::Version
95
116
  version: '0'
96
- type: :development
117
+ name: guard-rspec
97
118
  prerelease: false
119
+ type: :development
98
120
  version_requirements: !ruby/object:Gem::Requirement
99
121
  requirements:
100
122
  - - ">="
101
123
  - !ruby/object:Gem::Version
102
124
  version: '0'
103
125
  - !ruby/object:Gem::Dependency
104
- name: guard-rubocop
105
126
  requirement: !ruby/object:Gem::Requirement
106
127
  requirements:
107
128
  - - ">="
108
129
  - !ruby/object:Gem::Version
109
130
  version: '0'
110
- type: :development
131
+ name: guard-rubocop
111
132
  prerelease: false
133
+ type: :development
112
134
  version_requirements: !ruby/object:Gem::Requirement
113
135
  requirements:
114
136
  - - ">="
115
137
  - !ruby/object:Gem::Version
116
138
  version: '0'
117
139
  - !ruby/object:Gem::Dependency
118
- name: neo4j-rake_tasks
119
140
  requirement: !ruby/object:Gem::Requirement
120
141
  requirements:
121
142
  - - ">="
122
143
  - !ruby/object:Gem::Version
123
144
  version: 0.3.0
124
- type: :development
145
+ name: neo4j-rake_tasks
125
146
  prerelease: false
147
+ type: :development
126
148
  version_requirements: !ruby/object:Gem::Requirement
127
149
  requirements:
128
150
  - - ">="
129
151
  - !ruby/object:Gem::Version
130
152
  version: 0.3.0
131
153
  - !ruby/object:Gem::Dependency
132
- name: os
133
154
  requirement: !ruby/object:Gem::Requirement
134
155
  requirements:
135
156
  - - ">="
136
157
  - !ruby/object:Gem::Version
137
158
  version: '0'
138
- type: :development
159
+ name: os
139
160
  prerelease: false
161
+ type: :development
140
162
  version_requirements: !ruby/object:Gem::Requirement
141
163
  requirements:
142
164
  - - ">="
143
165
  - !ruby/object:Gem::Version
144
166
  version: '0'
145
167
  - !ruby/object:Gem::Dependency
146
- name: pry
147
168
  requirement: !ruby/object:Gem::Requirement
148
169
  requirements:
149
170
  - - ">="
150
171
  - !ruby/object:Gem::Version
151
172
  version: '0'
152
- type: :development
173
+ name: pry
153
174
  prerelease: false
175
+ type: :development
154
176
  version_requirements: !ruby/object:Gem::Requirement
155
177
  requirements:
156
178
  - - ">="
157
179
  - !ruby/object:Gem::Version
158
180
  version: '0'
159
181
  - !ruby/object:Gem::Dependency
160
- name: railties
161
182
  requirement: !ruby/object:Gem::Requirement
162
183
  requirements:
163
184
  - - ">="
164
185
  - !ruby/object:Gem::Version
165
186
  version: '4.0'
166
- type: :development
187
+ name: railties
167
188
  prerelease: false
189
+ type: :development
168
190
  version_requirements: !ruby/object:Gem::Requirement
169
191
  requirements:
170
192
  - - ">="
171
193
  - !ruby/object:Gem::Version
172
194
  version: '4.0'
173
195
  - !ruby/object:Gem::Dependency
174
- name: rake
175
196
  requirement: !ruby/object:Gem::Requirement
176
197
  requirements:
177
198
  - - ">="
178
199
  - !ruby/object:Gem::Version
179
200
  version: '0'
180
- type: :development
201
+ name: rake
181
202
  prerelease: false
203
+ type: :development
182
204
  version_requirements: !ruby/object:Gem::Requirement
183
205
  requirements:
184
206
  - - ">="
185
207
  - !ruby/object:Gem::Version
186
208
  version: '0'
187
209
  - !ruby/object:Gem::Dependency
188
- name: rubocop
189
210
  requirement: !ruby/object:Gem::Requirement
190
211
  requirements:
191
212
  - - "~>"
192
213
  - !ruby/object:Gem::Version
193
- version: 0.49.1
194
- type: :development
214
+ version: 0.56.0
215
+ name: rubocop
195
216
  prerelease: false
217
+ type: :development
196
218
  version_requirements: !ruby/object:Gem::Requirement
197
219
  requirements:
198
220
  - - "~>"
199
221
  - !ruby/object:Gem::Version
200
- version: 0.49.1
222
+ version: 0.56.0
201
223
  - !ruby/object:Gem::Dependency
202
- name: yard
203
224
  requirement: !ruby/object:Gem::Requirement
204
225
  requirements:
205
226
  - - ">="
206
227
  - !ruby/object:Gem::Version
207
228
  version: '0'
208
- type: :development
229
+ name: yard
209
230
  prerelease: false
231
+ type: :development
210
232
  version_requirements: !ruby/object:Gem::Requirement
211
233
  requirements:
212
234
  - - ">="
@@ -214,7 +236,7 @@ dependencies:
214
236
  version: '0'
215
237
  description: 'A Neo4j OGM (Object-Graph-Mapper) for Ruby heavily inspired by ActiveRecord.
216
238
 
217
- '
239
+ '
218
240
  email: andreas.ronge@gmail.com, public@brian-underwood.codes, chris@subvertallmedia.com
219
241
  executables:
220
242
  - neo4j-jars
@@ -283,7 +305,7 @@ files:
283
305
  - lib/neo4j/active_rel/validations.rb
284
306
  - lib/neo4j/class_arguments.rb
285
307
  - lib/neo4j/config.rb
286
- - lib/neo4j/core/query.rb
308
+ - lib/neo4j/core/query_ext.rb
287
309
  - lib/neo4j/errors.rb
288
310
  - lib/neo4j/migration.rb
289
311
  - lib/neo4j/migrations.rb
@@ -350,7 +372,7 @@ metadata:
350
372
  changelog_uri: https://github.com/neo4jrb/neo4j/blob/master/CHANGELOG.md
351
373
  source_code_uri: https://github.com/neo4jrb/neo4j/
352
374
  bug_tracker_uri: https://github.com/neo4jrb/neo4j/issues
353
- post_install_message:
375
+ post_install_message:
354
376
  rdoc_options:
355
377
  - "--quiet"
356
378
  - "--title"
@@ -365,7 +387,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
365
387
  requirements:
366
388
  - - ">="
367
389
  - !ruby/object:Gem::Version
368
- version: 2.1.9
390
+ version: 1.9.3
369
391
  required_rubygems_version: !ruby/object:Gem::Requirement
370
392
  requirements:
371
393
  - - ">="
@@ -373,8 +395,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
373
395
  version: '0'
374
396
  requirements: []
375
397
  rubyforge_project: neo4j
376
- rubygems_version: 2.6.14
377
- signing_key:
398
+ rubygems_version: 2.7.6
399
+ signing_key:
378
400
  specification_version: 4
379
401
  summary: A graph database for Ruby
380
402
  test_files: []
@@ -1,22 +0,0 @@
1
- module Neo4j::Core
2
- class Query
3
- # Creates a Neo4j::ActiveNode::Query::QueryProxy object that builds off of a Core::Query object.
4
- #
5
- # @param [Class] model An ActiveNode model to be used as the start of a new QueryuProxy chain
6
- # @param [Symbol] var The variable to be used to refer to the object from within the new QueryProxy
7
- # @param [Boolean] optional Indicate whether the new QueryProxy will use MATCH or OPTIONAL MATCH.
8
- # @return [Neo4j::ActiveNode::Query::QueryProxy] A QueryProxy object.
9
- def proxy_as(model, var, optional = false)
10
- # TODO: Discuss whether it's necessary to call `break` on the query or if this should be left to the user.
11
- Neo4j::ActiveNode::Query::QueryProxy.new(model, nil, node: var, optional: optional, starting_query: self, chain_level: @proxy_chain_level)
12
- end
13
-
14
- # Calls proxy_as with `optional` set true. This doesn't offer anything different from calling `proxy_as` directly but it may be more readable.
15
- def proxy_as_optional(model, var)
16
- proxy_as(model, var, true)
17
- end
18
-
19
- # For instances where you turn a QueryProxy into a Query and then back to a QueryProxy with `#proxy_as`
20
- attr_accessor :proxy_chain_level
21
- end
22
- end