neo4j 8.0.0.alpha.10 → 8.0.0.alpha.11
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 +37 -0
- data/lib/neo4j/active_node/has_n.rb +29 -7
- data/lib/neo4j/active_node/query/query_proxy.rb +17 -7
- data/lib/neo4j/active_node/query/query_proxy_enumerable.rb +2 -0
- data/lib/neo4j/active_node/query/query_proxy_link.rb +5 -1
- data/lib/neo4j/active_node/query/query_proxy_methods.rb +2 -0
- data/lib/neo4j/active_node/query/query_proxy_methods_of_mass_updating.rb +4 -1
- data/lib/neo4j/model_schema.rb +1 -0
- data/lib/neo4j/railtie.rb +11 -5
- data/lib/neo4j/shared/persistence.rb +12 -4
- data/lib/neo4j/shared/query_factory.rb +2 -1
- data/lib/neo4j/tasks/migration.rake +1 -1
- data/lib/neo4j/version.rb +1 -1
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92ded23c28b3eabbb9fa5dbcd51e95e694e0f4bb
|
4
|
+
data.tar.gz: f809277ed6c601b80ae90af8f7634a94e598474d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1c123b35850f7d765dda8cb3a9efc995338b3e9c612f452ba6bd1a7522f693460870300fa7e1883a2d0f7811b17c7ea3f6be0c1d46db0dec95f264d829ebc89
|
7
|
+
data.tar.gz: 7a5e8d189ff9a9ec644c3ac197e4c56de00f5552dd41d00c5b9b4c38e0e856b7e68b896733d76a7ee1f1d7bf4857f1549a56aa26be579ce6c325063116606c54
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,19 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
5
5
|
|
6
6
|
## [Unreleased]
|
7
7
|
|
8
|
+
|
9
|
+
## [8.0.0.alpha.11] 2016-09-27
|
10
|
+
|
11
|
+
### Fixed
|
12
|
+
- Don't fire database when accessing to unpersisted model associations (thanks @klobuczek & @ProGM see #1273)
|
13
|
+
- `size` and `length` methods not taking account of `@deferred_objects` (see #1293)
|
14
|
+
- `update` was not rolling-back association changes when validations fail
|
15
|
+
- Broken Rails `neo4j:migrate_v8` generator
|
16
|
+
|
17
|
+
# Changed
|
18
|
+
- `count` method in associations, now always fire the database like AR does
|
19
|
+
- Neo4j now passes all association validations specs, taken from AR (thanks @klobuczek)
|
20
|
+
|
8
21
|
## [8.0.0.alpha.10] 2016-09-16
|
9
22
|
|
10
23
|
### Fixed
|
@@ -113,12 +126,30 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
113
126
|
|
114
127
|
- Made some memory optimizations (thanks ProGM / see #1221)
|
115
128
|
|
129
|
+
## [7.2.2] - 09-22-2016
|
130
|
+
|
131
|
+
### Fixed
|
132
|
+
|
133
|
+
- `where` clause with question mark parameter and array values only using the first element (see #1247 #1290)
|
134
|
+
|
135
|
+
## [7.2.1] - 09-19-2016
|
136
|
+
|
137
|
+
### Fixed
|
138
|
+
|
139
|
+
- During ActiveRel create, node and rel property values formatted like Cypher props (`{val}`) were interpreted as props, causing errors.
|
140
|
+
|
116
141
|
## [7.2.0] - 08-23-2016
|
117
142
|
|
118
143
|
### Added
|
119
144
|
|
120
145
|
- Backporting #1245 to 7.x versions. It implements the [`ForbiddenAttributesProtection` API](http://edgeapi.rubyonrails.org/classes/ActionController/StrongParameters.html) from ActiveRecord.
|
121
146
|
|
147
|
+
## [7.1.4] - 09-20-2016
|
148
|
+
|
149
|
+
### Fixed
|
150
|
+
|
151
|
+
- `where` clause with question mark parameter and array values only using the first element (see #1247 #1290)
|
152
|
+
|
122
153
|
## [7.1.3] - 08-18-2016
|
123
154
|
|
124
155
|
### Changed
|
@@ -144,6 +175,12 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
144
175
|
- Gemspec dependency requirements were modified where ActiveModel, ActiveSupport, and Railties are concerned. The gem now requires >= 4.0, < 5.1.
|
145
176
|
- `ActiveModel::Serializers::Xml` is only included if supported if available.
|
146
177
|
|
178
|
+
## [7.0.16] - 09-20-2016
|
179
|
+
|
180
|
+
### Fixed
|
181
|
+
|
182
|
+
- `where` clause with question mark parameter and array values only using the first element (see #1247 #1290)
|
183
|
+
|
147
184
|
## [7.0.15] - 08-18-2016
|
148
185
|
|
149
186
|
### Changed
|
@@ -28,7 +28,7 @@ module Neo4j::ActiveNode
|
|
28
28
|
end
|
29
29
|
|
30
30
|
extend Forwardable
|
31
|
-
%w(include?
|
31
|
+
%w(include? find first last ==).each do |delegated_method|
|
32
32
|
def_delegator :@enumerable, delegated_method
|
33
33
|
end
|
34
34
|
|
@@ -38,6 +38,21 @@ module Neo4j::ActiveNode
|
|
38
38
|
result_nodes.each(&block)
|
39
39
|
end
|
40
40
|
|
41
|
+
# .count always hits the database
|
42
|
+
def_delegator :@query_proxy, :count
|
43
|
+
|
44
|
+
def length
|
45
|
+
@deferred_objects.length + @enumerable.length
|
46
|
+
end
|
47
|
+
|
48
|
+
def size
|
49
|
+
@deferred_objects.size + @enumerable.size
|
50
|
+
end
|
51
|
+
|
52
|
+
def empty?(*args)
|
53
|
+
@deferred_objects.empty? && @enumerable.empty?(*args)
|
54
|
+
end
|
55
|
+
|
41
56
|
def ==(other)
|
42
57
|
self.to_a == other.to_a
|
43
58
|
end
|
@@ -59,9 +74,7 @@ module Neo4j::ActiveNode
|
|
59
74
|
def result_nodes
|
60
75
|
return result_objects if !@query_proxy.model
|
61
76
|
|
62
|
-
result_objects
|
63
|
-
object.is_a?(Neo4j::ActiveNode) ? object : @query_proxy.model.find(object)
|
64
|
-
end
|
77
|
+
map_results_as_nodes(result_objects)
|
65
78
|
end
|
66
79
|
|
67
80
|
def result_objects
|
@@ -101,9 +114,12 @@ module Neo4j::ActiveNode
|
|
101
114
|
end
|
102
115
|
|
103
116
|
def replace_with(*args)
|
104
|
-
|
105
|
-
|
106
|
-
|
117
|
+
nodes = @query_proxy.replace_with(*args).to_a
|
118
|
+
if @query_proxy.start_object.try(:new_record?)
|
119
|
+
@cached_result = nil
|
120
|
+
else
|
121
|
+
cache_result(nodes)
|
122
|
+
end
|
107
123
|
end
|
108
124
|
|
109
125
|
QUERY_PROXY_METHODS = [:<<, :delete, :create, :pluck, :where, :where_not, :rel_where, :rel_order, :order, :skip, :limit]
|
@@ -132,6 +148,12 @@ module Neo4j::ActiveNode
|
|
132
148
|
|
133
149
|
private
|
134
150
|
|
151
|
+
def map_results_as_nodes(result)
|
152
|
+
result.map do |object|
|
153
|
+
object.is_a?(Neo4j::ActiveNode) ? object : @query_proxy.model.find(object)
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
135
157
|
def target_for_missing_method(method_name)
|
136
158
|
case method_name
|
137
159
|
when *CACHED_RESULT_METHODS
|
@@ -1,7 +1,9 @@
|
|
1
1
|
module Neo4j
|
2
2
|
module ActiveNode
|
3
3
|
module Query
|
4
|
+
# rubocop:disable Metrics/ClassLength
|
4
5
|
class QueryProxy
|
6
|
+
# rubocop:enable Metrics/ClassLength
|
5
7
|
include Neo4j::ActiveNode::Query::QueryProxyEnumerable
|
6
8
|
include Neo4j::ActiveNode::Query::QueryProxyMethods
|
7
9
|
include Neo4j::ActiveNode::Query::QueryProxyMethodsOfMassUpdating
|
@@ -165,13 +167,7 @@ module Neo4j
|
|
165
167
|
|
166
168
|
# To add a relationship for the node for the association on this QueryProxy
|
167
169
|
def <<(other_node)
|
168
|
-
|
169
|
-
create(other_node, {})
|
170
|
-
elsif @association
|
171
|
-
@start_object.defer_create(@association.name, other_node)
|
172
|
-
else
|
173
|
-
fail 'Another crazy error!'
|
174
|
-
end
|
170
|
+
_create_relation_or_defer(other_node)
|
175
171
|
self
|
176
172
|
end
|
177
173
|
|
@@ -266,8 +262,22 @@ module Neo4j
|
|
266
262
|
end
|
267
263
|
end
|
268
264
|
|
265
|
+
def unpersisted_start_object?
|
266
|
+
@start_object && @start_object.new_record?
|
267
|
+
end
|
268
|
+
|
269
269
|
protected
|
270
270
|
|
271
|
+
def _create_relation_or_defer(other_node)
|
272
|
+
if @start_object._persisted_obj
|
273
|
+
create(other_node, {})
|
274
|
+
elsif @association
|
275
|
+
@start_object.defer_create(@association.name, other_node)
|
276
|
+
else
|
277
|
+
fail 'Another crazy error!'
|
278
|
+
end
|
279
|
+
end
|
280
|
+
|
271
281
|
# Methods are underscored to prevent conflict with user class methods
|
272
282
|
def _add_params(params)
|
273
283
|
@params = @params.merge(params)
|
@@ -39,6 +39,7 @@ module Neo4j
|
|
39
39
|
|
40
40
|
# @return [Integer] number of nodes of this class
|
41
41
|
def count(distinct = nil, target = nil)
|
42
|
+
return 0 if unpersisted_start_object?
|
42
43
|
fail(Neo4j::InvalidParameterError, ':count accepts `distinct` or nil as a parameter') unless distinct.nil? || distinct == :distinct
|
43
44
|
query_with_target(target) do |var|
|
44
45
|
q = distinct.nil? ? var : "DISTINCT #{var}"
|
@@ -61,6 +62,7 @@ module Neo4j
|
|
61
62
|
end
|
62
63
|
|
63
64
|
def empty?(target = nil)
|
65
|
+
return true if unpersisted_start_object?
|
64
66
|
query_with_target(target) { |var| !self.exists?(nil, var) }
|
65
67
|
end
|
66
68
|
|
@@ -52,7 +52,10 @@ module Neo4j
|
|
52
52
|
nodes = Array(node_or_nodes)
|
53
53
|
|
54
54
|
self.delete_all_rels
|
55
|
-
nodes.
|
55
|
+
nodes.map do |node|
|
56
|
+
node if _create_relation_or_defer(node)
|
57
|
+
end.compact
|
58
|
+
# nodes.each { |node| self << node }
|
56
59
|
end
|
57
60
|
|
58
61
|
# Returns all relationships between a node and its last link in the QueryProxy chain, destroys them in Ruby. Callbacks will be run.
|
data/lib/neo4j/model_schema.rb
CHANGED
@@ -80,6 +80,7 @@ module Neo4j
|
|
80
80
|
end
|
81
81
|
|
82
82
|
def legacy_model_schema_informations
|
83
|
+
ensure_model_data_state!
|
83
84
|
data = {index: [], constraint: []}
|
84
85
|
each_schema_element do |type, model, label, property_name|
|
85
86
|
data[type] << {label: label, property_name: property_name, model: model}
|
data/lib/neo4j/railtie.rb
CHANGED
@@ -9,7 +9,11 @@ require 'neo4j/core/cypher_session/adaptors/embedded'
|
|
9
9
|
|
10
10
|
module Neo4j
|
11
11
|
class Railtie < ::Rails::Railtie
|
12
|
-
|
12
|
+
def empty_config
|
13
|
+
ActiveSupport::OrderedOptions.new.tap { |cfg| cfg.session = ActiveSupport::OrderedOptions.new }
|
14
|
+
end
|
15
|
+
|
16
|
+
config.neo4j = empty_config
|
13
17
|
|
14
18
|
if defined?(ActiveSupport::Reloader)
|
15
19
|
ActiveSupport::Reloader.to_prepare do
|
@@ -57,8 +61,8 @@ module Neo4j
|
|
57
61
|
end
|
58
62
|
end
|
59
63
|
|
60
|
-
def setup!(neo4j_config =
|
61
|
-
type, url, path, options, wait_for_connection = final_config!(neo4j_config).values_at(:type, :
|
64
|
+
def setup!(neo4j_config = empty_config)
|
65
|
+
type, url, path, options, wait_for_connection = final_config!(neo4j_config).values_at(:type, :url, :path, :options, :wait_for_connection)
|
62
66
|
register_neo4j_cypher_logging(type || default_session_type)
|
63
67
|
|
64
68
|
Neo4j::SessionManager.open_neo4j_session(type || default_session_type,
|
@@ -74,8 +78,10 @@ module Neo4j
|
|
74
78
|
end
|
75
79
|
|
76
80
|
def support_deprecated_session_configs!(neo4j_config)
|
77
|
-
|
78
|
-
|
81
|
+
if neo4j_config.sessions.present?
|
82
|
+
ActiveSupport::Deprecation.warn('neo4j.config.sessions is deprecated, please use neo4j.config.session (not an array)')
|
83
|
+
neo4j_config.session = neo4j_config.sessions[0] if neo4j_config.session.empty?
|
84
|
+
end
|
79
85
|
|
80
86
|
%w(type path url options).each do |key|
|
81
87
|
value = neo4j_config.send("session_#{key}")
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module Neo4j::Shared
|
2
|
+
# rubocop:disable Metrics/ModuleLength
|
2
3
|
module Persistence
|
4
|
+
# rubocop:enable Metrics/ModuleLength
|
3
5
|
extend ActiveSupport::Concern
|
4
6
|
|
5
7
|
# @return [Hash] Given a node's state, will call the appropriate `props_for_{action}` method.
|
@@ -172,15 +174,21 @@ module Neo4j::Shared
|
|
172
174
|
# Updates this resource with all the attributes from the passed-in Hash and requests that the record be saved.
|
173
175
|
# If saving fails because the resource is invalid then false will be returned.
|
174
176
|
def update(attributes)
|
175
|
-
self.
|
176
|
-
|
177
|
+
self.class.run_transaction do |tx|
|
178
|
+
self.attributes = process_attributes(attributes)
|
179
|
+
saved = save
|
180
|
+
tx.mark_failed unless saved
|
181
|
+
saved
|
182
|
+
end
|
177
183
|
end
|
178
184
|
alias update_attributes update
|
179
185
|
|
180
186
|
# Same as {#update_attributes}, but raises an exception if saving fails.
|
181
187
|
def update!(attributes)
|
182
|
-
self.
|
183
|
-
|
188
|
+
self.class.run_transaction do
|
189
|
+
self.attributes = process_attributes(attributes)
|
190
|
+
save!
|
191
|
+
end
|
184
192
|
end
|
185
193
|
alias update_attributes! update!
|
186
194
|
|
@@ -69,7 +69,8 @@ module Neo4j::Shared
|
|
69
69
|
|
70
70
|
def create_query
|
71
71
|
return match_query if graph_object.persisted?
|
72
|
-
|
72
|
+
labels = graph_object.labels_for_create.map { |l| ":`#{l}`" }.join
|
73
|
+
base_query.create("(#{identifier}#{labels} {#{identifier}_params})").params(identifier_params => graph_object.props_for_create)
|
73
74
|
end
|
74
75
|
end
|
75
76
|
|
data/lib/neo4j/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: neo4j
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 8.0.0.alpha.
|
4
|
+
version: 8.0.0.alpha.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andreas Ronge, Brian Underwood, Chris Grigg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: orm_adapter
|
@@ -370,4 +370,3 @@ signing_key:
|
|
370
370
|
specification_version: 4
|
371
371
|
summary: A graph database for Ruby
|
372
372
|
test_files: []
|
373
|
-
has_rdoc: true
|