neo4j 5.2.3 → 5.2.5
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 +20 -0
- data/lib/neo4j/active_node/persistence.rb +7 -20
- data/lib/neo4j/active_node/property.rb +2 -2
- data/lib/neo4j/railtie.rb +1 -1
- data/lib/neo4j/shared/declared_property_manager.rb +1 -1
- data/lib/neo4j/shared/persistence.rb +11 -1
- data/lib/neo4j/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 662aa756b654f9c55878f640b07a1df6438c1b59
|
4
|
+
data.tar.gz: 7b88ef87ef0ba7e99722f1f398ea3b9efdc1a141
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c6664caf99d0bd2434668c0429583b16fba18565be3289d8f2e92161eff21784ad124cf716570e910493c23bfb7306e1ad5604a64504d047ccad30d9d01b6c9
|
7
|
+
data.tar.gz: a87e1bf6c26ebb37891e7210e4c37a2c14a848eb1257bec1aa5791d302ebffc9e846074c892dd3d12917277938568c9e3a956dde023bc7dbf04374d83e511bfd
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,22 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
5
5
|
|
6
6
|
## [Unreleased][unreleased]
|
7
7
|
|
8
|
+
## [5.2.5] - 09-11-2015
|
9
|
+
|
10
|
+
### Fixed
|
11
|
+
|
12
|
+
- Regression in last release caused properties to revert to default on update if not present in the properties for update
|
13
|
+
|
14
|
+
## [5.2.4] - 09-11-2015
|
15
|
+
|
16
|
+
### Fixed
|
17
|
+
- Use `debug` log level for query logging
|
18
|
+
- `updated_at` properties were not being added up `update` events, only updated.
|
19
|
+
- Default values of Boolean properties were not being set when `default: false`
|
20
|
+
- `props_for_update` was using String keys instead of Symbols, like `props_for_update`
|
21
|
+
- `props_for_create` and `props_for_update` were not adding default property values to the hash.
|
22
|
+
- ActiveNode's `merge` and `find_or_create` methods were not setting default values of declared properties when `ON CREATE` was triggered. The code now uses `props_for_create`.
|
23
|
+
|
8
24
|
## [5.2.3] - 09-07-2015
|
9
25
|
|
10
26
|
Added bugfixes from 5.1.4 and 5.1.5 that were missed in earlier 5.2.x releases:
|
@@ -30,6 +46,10 @@ Added bugfixes from 5.1.4 and 5.1.5 that were missed in earlier 5.2.x releases:
|
|
30
46
|
- Added `record_timestamps` configuration do default all `ActiveNode` and `ActiveRel` models to have `created_at` and `updated_at` timestamps (from #939, thanks @rebecca-eakins)
|
31
47
|
- Added `timestamp_type` configuration to specify how timestamps should be stored (from #939, thanks @rebecca-eakins)
|
32
48
|
|
49
|
+
### Changed
|
50
|
+
- Methods related to basic node and rel persistence (`save`, `create_model`, `_create_node`, others) were refactored to make the processes simpler, clearer, and slightly faster.
|
51
|
+
- Unit test directory structure was rearranged to mirror the `lib` directory.
|
52
|
+
|
33
53
|
## [5.1.3] - 08-23-2015
|
34
54
|
|
35
55
|
### Fixed
|
@@ -63,6 +63,11 @@ module Neo4j::ActiveNode
|
|
63
63
|
self.class.neo4j_session.create_node(node_props, labels)
|
64
64
|
end
|
65
65
|
|
66
|
+
# As the name suggests, this inserts the primary key (id property) into the properties hash.
|
67
|
+
# The method called here, `default_property_values`, is a holdover from an earlier version of the gem. It does NOT
|
68
|
+
# contain the default values of properties, it contains the Default Property, which we now refer to as the ID Property.
|
69
|
+
# It will be deprecated and renamed in a coming refactor.
|
70
|
+
# @param [Hash] converted_props A hash of properties post-typeconversion, ready for insertion into the DB.
|
66
71
|
def inject_primary_key!(converted_props)
|
67
72
|
self.class.default_property_values(self).tap do |destination_props|
|
68
73
|
destination_props.merge!(converted_props) if converted_props.is_a?(Hash)
|
@@ -148,29 +153,11 @@ module Neo4j::ActiveNode
|
|
148
153
|
private
|
149
154
|
|
150
155
|
def on_create_props(find_attributes)
|
151
|
-
|
152
|
-
now = DateTime.now.to_i
|
153
|
-
set_props_timestamp!('created_at', props, now)
|
154
|
-
set_props_timestamp!('updated_at', props, now)
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
# The process of creating custom id_property values is different from auto uuids. This adapts to that, calls the appropriate method,
|
159
|
-
# and raises an error if it fails.
|
160
|
-
def id_prop_val(find_attributes)
|
161
|
-
custom_uuid_method = id_property_info[:type][:on]
|
162
|
-
id_prop_val = custom_uuid_method ? self.new(find_attributes).send(custom_uuid_method) : default_properties[id_property_name].call
|
163
|
-
fail 'Unable to create custom id property' if id_prop_val.nil?
|
164
|
-
id_prop_val
|
156
|
+
find_attributes.merge(self.new(find_attributes).props_for_create)
|
165
157
|
end
|
166
158
|
|
167
159
|
def on_match_props
|
168
|
-
|
169
|
-
end
|
170
|
-
|
171
|
-
def set_props_timestamp!(key_name, props = {}, stamp = DateTime.now.to_i)
|
172
|
-
props[key_name.to_sym] = stamp if attributes_nil_hash.key?(key_name)
|
173
|
-
props
|
160
|
+
{}.tap { |props| props[:updated_at] = DateTime.now.to_i if attributes_nil_hash.key?('updated_at'.freeze) }
|
174
161
|
end
|
175
162
|
end
|
176
163
|
end
|
@@ -27,8 +27,8 @@ module Neo4j::ActiveNode
|
|
27
27
|
|
28
28
|
def contains_association?(attributes)
|
29
29
|
return false unless attributes
|
30
|
-
|
31
|
-
|
30
|
+
attributes.each_key { |k| return true if association_key?(k) }
|
31
|
+
false
|
32
32
|
end
|
33
33
|
|
34
34
|
# All keys which could be association setter methods (including _id/_ids)
|
data/lib/neo4j/railtie.rb
CHANGED
@@ -79,7 +79,7 @@ module Neo4j
|
|
79
79
|
Neo4j::Core::Query.pretty_cypher = Neo4j::Config[:pretty_logged_cypher_queries]
|
80
80
|
|
81
81
|
Neo4j::Server::CypherSession.log_with do |message|
|
82
|
-
(Neo4j::Config[:logger] || Rails.logger).
|
82
|
+
(Neo4j::Config[:logger] || Rails.logger).debug message
|
83
83
|
end
|
84
84
|
|
85
85
|
@neo4j_cypher_logging_registered = true
|
@@ -24,7 +24,7 @@ module Neo4j::Shared
|
|
24
24
|
@_attributes_string_map = nil
|
25
25
|
registered_properties[property.name] = property
|
26
26
|
register_magic_typecaster(property) if property.magic_typecaster
|
27
|
-
declared_property_defaults[property.name] = property.default_value if property.default_value
|
27
|
+
declared_property_defaults[property.name] = property.default_value if !property.default_value.nil?
|
28
28
|
end
|
29
29
|
|
30
30
|
# The :default option in Neo4j::ActiveNode#property class method allows for setting a default value instead of
|
@@ -27,6 +27,7 @@ module Neo4j::Shared
|
|
27
27
|
inject_timestamps!
|
28
28
|
converted_props = props_for_db(props)
|
29
29
|
inject_classname!(converted_props)
|
30
|
+
inject_defaults!(converted_props)
|
30
31
|
return converted_props unless self.class.respond_to?(:default_property_values)
|
31
32
|
inject_primary_key!(converted_props)
|
32
33
|
end
|
@@ -35,7 +36,9 @@ module Neo4j::Shared
|
|
35
36
|
def props_for_update
|
36
37
|
update_magic_properties
|
37
38
|
changed_props = attributes.select { |k, _| changed_attributes.include?(k) }
|
39
|
+
changed_props.symbolize_keys!
|
38
40
|
props_for_db(changed_props)
|
41
|
+
inject_defaults!(changed_props)
|
39
42
|
end
|
40
43
|
|
41
44
|
# Convenience method to set attribute and #save at the same time
|
@@ -193,7 +196,7 @@ module Neo4j::Shared
|
|
193
196
|
end
|
194
197
|
|
195
198
|
def update_magic_properties
|
196
|
-
self.updated_at = DateTime.now if respond_to?(:updated_at=) && changed? && !updated_at_changed?
|
199
|
+
self.updated_at = DateTime.now if respond_to?(:updated_at=) && (updated_at.nil? || (changed? && !updated_at_changed?))
|
197
200
|
end
|
198
201
|
|
199
202
|
# Inserts the _classname property into an object's properties during object creation.
|
@@ -213,6 +216,13 @@ module Neo4j::Shared
|
|
213
216
|
self.updated_at ||= now if respond_to?(:updated_at=)
|
214
217
|
end
|
215
218
|
|
219
|
+
def inject_defaults!(properties)
|
220
|
+
self.class.declared_property_manager.declared_property_defaults.each_pair do |k, v|
|
221
|
+
properties[k.to_sym] = v if send(k).nil?
|
222
|
+
end
|
223
|
+
properties
|
224
|
+
end
|
225
|
+
|
216
226
|
def set_timestamps
|
217
227
|
warning = 'This method has been replaced with `inject_timestamps!` and will be removed in a future version'.freeze
|
218
228
|
ActiveSupport::Deprecation.warn warning, caller
|
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: 5.2.
|
4
|
+
version: 5.2.5
|
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: 2015-09-
|
11
|
+
date: 2015-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: orm_adapter
|