neo4j 9.5.2 → 9.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/config/neo4j/config.yml +3 -0
- data/lib/neo4j/active_node/has_n.rb +20 -7
- data/lib/neo4j/active_node/query/query_proxy.rb +1 -1
- data/lib/neo4j/active_node/rels.rb +0 -12
- data/lib/neo4j/active_rel/persistence.rb +5 -4
- data/lib/neo4j/version.rb +1 -1
- data/neo4j.gemspec +2 -2
- metadata +14 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 822965793898b0cdde8a1e6410520b411478b84e849ee4130a53e6391858f8c4
|
4
|
+
data.tar.gz: c92710ffdbca32f588378bf11ea0466fc69233f571656e499b0287fa685f1578
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff8a3d6a6122ad2f9fee70dcafbb10a2c30de757c0d98b755547334d56b5df020ae66eebaa12750dbdb2ab418a57ee071fd736960225426e0d55bef178e104bf
|
7
|
+
data.tar.gz: 19a8e93b5dd488c8d119d48230a02127b2622842de1adda468fe57f996ad00ec128f927e2b05e5ddea2cf4fd298cde324a5c7f3c90a16473614ea48ca838563f
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,13 @@ 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.5.3] 2019-08-16
|
7
|
+
|
8
|
+
## Fixed
|
9
|
+
|
10
|
+
- Enforces has_one uniqness constraint on relationship with config flag. (#1566)
|
11
|
+
- Restricting activemodel and activesupport version to < 6.0.
|
12
|
+
|
6
13
|
## [9.5.2] 2019-08-06
|
7
14
|
|
8
15
|
## Fixed
|
data/config/neo4j/config.yml
CHANGED
@@ -3,7 +3,7 @@ module Neo4j::ActiveNode
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
class NonPersistedNodeError < Neo4j::Error; end
|
6
|
-
|
6
|
+
class HasOneConstraintError < Neo4j::Error; end
|
7
7
|
# Return this object from associations
|
8
8
|
# It uses a QueryProxy to get results
|
9
9
|
# But also caches results and can have results cached on it
|
@@ -229,14 +229,27 @@ module Neo4j::ActiveNode
|
|
229
229
|
end
|
230
230
|
end
|
231
231
|
|
232
|
-
def
|
233
|
-
|
234
|
-
|
232
|
+
def validate_reverse_has_one_core_rel(association, other_node)
|
233
|
+
return unless Neo4j::Config[:enforce_has_one]
|
234
|
+
reverse_assoc = reverse_association(association)
|
235
|
+
validate_has_one_rel!(reverse_assoc, other_node) if reverse_assoc && reverse_assoc.type == :has_one
|
236
|
+
end
|
237
|
+
|
238
|
+
def reverse_association(association)
|
239
|
+
reverse_assoc = self.class.associations.find do |_key, assoc|
|
240
|
+
association.inverse_of?(assoc) || assoc.inverse_of?(association)
|
241
|
+
end
|
242
|
+
reverse_assoc && reverse_assoc.last
|
243
|
+
end
|
244
|
+
|
245
|
+
def validate_reverse_has_one_active_rel(active_rel, direction, other_node)
|
246
|
+
rel = active_rel_corresponding_rel(active_rel, direction, other_node.class)
|
247
|
+
validate_has_one_rel!(rel.last, other_node) if rel && rel.last.type == :has_one
|
235
248
|
end
|
236
249
|
|
237
|
-
def
|
238
|
-
send(
|
239
|
-
|
250
|
+
def validate_has_one_rel!(rel, other_node)
|
251
|
+
raise_error = (node = send(rel.name.to_s)) && node != other_node
|
252
|
+
fail(HasOneConstraintError, "node #{self.class}##{neo_id} has a has_one relationship with #{other_node.class}##{other_node.neo_id}") if raise_error
|
240
253
|
end
|
241
254
|
|
242
255
|
def active_rel_corresponding_rel(active_rel, direction, target_class)
|
@@ -208,7 +208,7 @@ module Neo4j
|
|
208
208
|
Neo4j::ActiveBase.run_transaction do
|
209
209
|
other_nodes.each do |other_node|
|
210
210
|
if other_node.neo_id
|
211
|
-
other_node.try(:
|
211
|
+
other_node.try(:validate_reverse_has_one_core_rel, association, @start_object)
|
212
212
|
else
|
213
213
|
other_node.save
|
214
214
|
end
|
@@ -7,17 +7,5 @@ module Neo4j::ActiveNode
|
|
7
7
|
fail "Can't access relationship on a non persisted node" unless _persisted_obj
|
8
8
|
_persisted_obj
|
9
9
|
end
|
10
|
-
|
11
|
-
def delete_reverse_relationship(association)
|
12
|
-
reverse_assoc = reverse_association(association)
|
13
|
-
delete_rel(reverse_assoc) if reverse_assoc && reverse_assoc.type == :has_one
|
14
|
-
end
|
15
|
-
|
16
|
-
def reverse_association(association)
|
17
|
-
reverse_assoc = self.class.associations.find do |_key, assoc|
|
18
|
-
association.inverse_of?(assoc) || assoc.inverse_of?(association)
|
19
|
-
end
|
20
|
-
reverse_assoc && reverse_assoc.last
|
21
|
-
end
|
22
10
|
end
|
23
11
|
end
|
@@ -45,16 +45,17 @@ module Neo4j::ActiveRel
|
|
45
45
|
|
46
46
|
def create_model
|
47
47
|
validate_node_classes!
|
48
|
-
|
48
|
+
validate_has_one_rel
|
49
49
|
rel = _create_rel
|
50
50
|
return self unless rel.respond_to?(:props)
|
51
51
|
init_on_load(rel, from_node, to_node, @rel_type)
|
52
52
|
true
|
53
53
|
end
|
54
54
|
|
55
|
-
def
|
56
|
-
|
57
|
-
|
55
|
+
def validate_has_one_rel
|
56
|
+
return unless Neo4j::Config[:enforce_has_one]
|
57
|
+
to_node.validate_reverse_has_one_active_rel(self, :in, from_node) if to_node.persisted?
|
58
|
+
from_node.validate_reverse_has_one_active_rel(self, :out, to_node) if from_node.persisted?
|
58
59
|
end
|
59
60
|
|
60
61
|
def query_as(var)
|
data/lib/neo4j/version.rb
CHANGED
data/neo4j.gemspec
CHANGED
@@ -33,8 +33,8 @@ DESCRIPTION
|
|
33
33
|
'bug_tracker_uri' => 'https://github.com/neo4jrb/neo4j/issues'
|
34
34
|
}
|
35
35
|
|
36
|
-
s.add_dependency('activemodel', '>= 4.0')
|
37
|
-
s.add_dependency('activesupport', '>= 4.0')
|
36
|
+
s.add_dependency('activemodel', ['>= 4.0', '< 6'])
|
37
|
+
s.add_dependency('activesupport', ['>= 4.0', '< 6'])
|
38
38
|
s.add_dependency('i18n', '!= 1.3.0') # version 1.3.0 introduced a bug with `symbolize_key`
|
39
39
|
s.add_dependency('neo4j-core', '>= 9.0.0')
|
40
40
|
s.add_dependency('orm_adapter', '~> 0.5.0')
|
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: 9.5.
|
4
|
+
version: 9.5.3
|
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: 2019-08-
|
11
|
+
date: 2019-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -17,6 +17,9 @@ dependencies:
|
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '4.0'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '6'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -24,6 +27,9 @@ dependencies:
|
|
24
27
|
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '4.0'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '6'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: activesupport
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -31,6 +37,9 @@ dependencies:
|
|
31
37
|
- - ">="
|
32
38
|
- !ruby/object:Gem::Version
|
33
39
|
version: '4.0'
|
40
|
+
- - "<"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '6'
|
34
43
|
type: :runtime
|
35
44
|
prerelease: false
|
36
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -38,6 +47,9 @@ dependencies:
|
|
38
47
|
- - ">="
|
39
48
|
- !ruby/object:Gem::Version
|
40
49
|
version: '4.0'
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '6'
|
41
53
|
- !ruby/object:Gem::Dependency
|
42
54
|
name: i18n
|
43
55
|
requirement: !ruby/object:Gem::Requirement
|