activegraph 10.0.0 → 10.1.1

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
2
  SHA256:
3
- metadata.gz: 66259444a09dbe560ec1a284b7c1988b24eaf4b29386efb63664cef081edf520
4
- data.tar.gz: ec43759b43c92f62a93589225207e0d37ef1d18ee4b61d5f4f204b89b8985787
3
+ metadata.gz: 65cca8a21c8ecb9dff1f8fdf38ab82bcbc02fb211bc29a1b50f947e1d4126b9f
4
+ data.tar.gz: c64ebb3dff76ec6b66eebe3499aef2fb15a1db56cf786e2da250e0ace1e6bcb8
5
5
  SHA512:
6
- metadata.gz: ec40cecc16c133c065672a3aa37360c304bba5cf24fe430dda7a789885262a7b239b798a7998b6d96b34ba8d05d5d0376c134dc829d6db0800e392fb740c0ec7
7
- data.tar.gz: 9f7fc129cf6916cdf69373ebb789ff7bc5f6c38c675d3e51403c4b0e6e7135a9649cfb2f3f754634507979a371de2a6a16f8670c765e38a016627c21f04e8535
6
+ metadata.gz: 898089b35cfcf2d101103ada41f27c1884cb00d9169b802526d4573af60cc577a8ddbb3ca71be96d9e54202a95a7a560448b6b27bdd57ff964b6d9e0b4f8b2e5
7
+ data.tar.gz: 3c3f46755b637e4cdc663f450dc5d247720cee609ae14fa00de87c01f9c9fe09a96d6e9a2bf9b3967f56460444946b35654061ef4cd24e36d9a7acadd20d7f89
data/CHANGELOG.md CHANGED
@@ -3,6 +3,35 @@ 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
+ ## [10.1.1] 2021-11-05
7
+
8
+ ## Fixed
9
+
10
+ - Fixed issue where some has_one relationships where incorrectly deleted disregarding direction
11
+ - It changes the relationship length assignment in query proxy eagerloading module to be consistent with query proxy relationship length syntax.
12
+
13
+ ## [10.1.0] 2021-02-05
14
+
15
+ ## Added
16
+
17
+ - support for ruby 3.0.0
18
+
19
+ ## [10.0.2] 2020-12-08
20
+
21
+ ## Fixed
22
+
23
+ - fixed bad require (https://github.com/neo4jrb/activegraph/issues/1634)
24
+ - removed unused exception class (Thanks @joshjordan)
25
+ - prevented after_commit callbacks from being called multiple times (Thanks @joshjordan)
26
+
27
+ ## [10.0.1] 2020-07-26
28
+
29
+ ## Fixed
30
+
31
+ - fixed incorrect id comparison, which could result in lost relationships (https://github.com/neo4jrb/activegraph/issues/1611)
32
+ - brought back BigDecimalConverter
33
+ - fixed rails template (Thanks @ekampp)
34
+
6
35
  ## [10.0.0] 2020-07-06
7
36
 
8
37
  - neo4j 4.0 support (default database only)
data/Gemfile CHANGED
@@ -7,7 +7,7 @@ gemspec
7
7
  gem 'listen', '< 3.1'
8
8
 
9
9
  active_model_version = ENV['ACTIVE_MODEL_VERSION']
10
- gem 'activemodel', "~> #{active_model_version}" if active_model_version
10
+ gem 'activemodel', "~> #{active_model_version}" if active_model_version&.length&.positive?
11
11
 
12
12
  group 'test' do
13
13
  gem 'coveralls', require: false
@@ -15,7 +15,6 @@ group 'test' do
15
15
  gem 'codecov', require: false
16
16
  gem 'simplecov', require: false
17
17
  gem 'simplecov-html', require: false
18
- gem 'rspec', '~> 3.4'
19
18
  gem 'its'
20
19
  gem 'test-unit'
21
20
  gem 'colored'
data/README.md CHANGED
@@ -45,31 +45,33 @@ Neo4j.rb v4.1.0 was released in January of 2015. Its changes are outlined [here]
45
45
 
46
46
  ## Neo4j version support
47
47
 
48
- | **Neo4j Version** | v2.x | v3.x | >= v4.x | >= 7.0.3 | activegraph 10.0 |
49
- |-------------------|------|-------|---------|----------|------------------|
50
- | 1.9.x | Yes | No | No | No | No |
51
- | 2.0.x | No | Yes | No | No | No |
52
- | 2.1.x | No | Yes | Yes * | Yes | No |
53
- | 2.2.x | No | No | Yes | Yes | No |
54
- | 2.3.x | No | No | Yes | Yes | No |
55
- | 3.0, 3.1, 3.3 | No | No | No | Yes | No |
56
- | 3.4, 3.5 | No | No | No | Yes | Yes |
57
- | 4.0 | No | No | No | No | Yes |
58
- | 4.1 | No | No | No | No | No |
48
+ | **Neo4j Version** | v2.x | v3.x | >= v4.x | >= 7.0.3 | activegraph 10.0 | activegraph 11.0.0.beta.4-java |
49
+ |-------------------|------|-------|---------|----------|------------------|--------------------------------|
50
+ | 1.9.x | Yes | No | No | No | No | No
51
+ | 2.0.x | No | Yes | No | No | No | No
52
+ | 2.1.x | No | Yes | Yes * | Yes | No | No
53
+ | 2.2.x | No | No | Yes | Yes | No | No
54
+ | 2.3.x | No | No | Yes | Yes | No | No
55
+ | 3.0, 3.1, 3.3 | No | No | No | Yes | No | No
56
+ | 3.4 | No | No | No | Yes | Yes | No
57
+ | 3.5 | No | No | No | Yes | Yes | Yes
58
+ | 4.0 | No | No | No | No | Yes | Yes
59
+ | 4.1 | No | No | No | No | No | Yes
60
+ | 4.2 | No | No | No | No | No | Yes
59
61
 
60
62
  `*` Neo4j.rb >= 4.x doesn't support Neo4j versions before 2.1.5. To use 2.1.x you should upgrade to a version >= 2.1.5
61
63
 
62
64
  ## Neo4j feature support
63
65
 
64
- | **Neo4j Feature** | v2.x | v3.x | >= v4.x | >= 8.x | activegraph 10.0 |
65
- |----------------------------|--------|------|---------|--------|------------------|
66
- | Bolt Protocol | No | No | No | Yes | Yes |
67
- | Auth | No | No | Yes | Yes | Yes |
68
- | Remote Cypher | Yes | Yes | Yes | Yes | No |
69
- | Transactions | Yes | Yes | Yes | Yes | Yes |
70
- | High Availability | No | Yes | Yes | Yes | Yes |
71
- | Causal Cluster | No | No | No | No | Yes |
72
- | Embedded JVM support | Yes | Yes | Yes | Yes | via bolt only |
66
+ | **Neo4j Feature** | v2.x | v3.x | >= v4.x | >= 8.x | >= activegraph 10.0 |
67
+ |----------------------------|--------|------|---------|--------|---------------------|
68
+ | Bolt Protocol | No | No | No | Yes | Yes |
69
+ | Auth | No | No | Yes | Yes | Yes |
70
+ | Remote Cypher | Yes | Yes | Yes | Yes | No |
71
+ | Transactions | Yes | Yes | Yes | Yes | Yes |
72
+ | High Availability | No | Yes | Yes | Yes | Yes |
73
+ | Causal Cluster | No | No | No | No | Yes |
74
+ | Embedded JVM support | Yes | Yes | Yes | Yes | via bolt only |
73
75
 
74
76
  ## Documentation
75
77
 
data/activegraph.gemspec CHANGED
@@ -32,13 +32,14 @@ DESCRIPTION
32
32
 
33
33
  s.add_dependency('activemodel', '>= 4.0')
34
34
  s.add_dependency('activesupport', '>= 4.0')
35
- s.add_dependency('i18n', '!= 1.3.0') # version 1.3.0 introduced a bug with `symbolize_key`
35
+ s.add_dependency('i18n', '!= 1.8.8') # https://github.com/jruby/jruby/issues/6547
36
36
  s.add_dependency('orm_adapter', '~> 0.5.0')
37
+ s.add_dependency('sorted_set')
37
38
  s.add_development_dependency('guard')
38
39
  s.add_development_dependency('guard-rspec')
39
40
  s.add_development_dependency('guard-rubocop')
40
41
  s.add_development_dependency('neo4j-rake_tasks', '>= 0.3.0')
41
- s.add_development_dependency("neo4j-#{ENV['driver'] == 'java' ? 'java' : 'ruby'}-driver", '~> 1.7.0')
42
+ s.add_development_dependency("neo4j-#{ENV['driver'] == 'java' ? 'java' : 'ruby'}-driver", '~> 1.7.4')
42
43
  s.add_development_dependency('os')
43
44
  s.add_development_dependency('pry')
44
45
  s.add_development_dependency('railties', '>= 4.0')
@@ -46,4 +47,5 @@ DESCRIPTION
46
47
  s.add_development_dependency('rubocop', '>= 0.56.0')
47
48
  s.add_development_dependency('yard')
48
49
  s.add_development_dependency('dryspec')
50
+ s.add_development_dependency('rspec', '< 3.10') # Cannot proxy frozen objects
49
51
  end
@@ -1,15 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'sorted_set'
4
+
1
5
  module ActiveGraph
2
6
  module Migrations
3
7
  class Runner
4
- STATUS_TABLE_FORMAT = '%-10s %-20s %s'.freeze
5
- SEPARATOR = '--------------------------------------------------'.freeze
6
- FILE_MISSING = '**** file missing ****'.freeze
7
- STATUS_TABLE_HEADER = ['Status'.freeze, 'Migration ID'.freeze, 'Migration Name'.freeze].freeze
8
- UP_MESSAGE = 'up'.freeze
9
- DOWN_MESSAGE = 'down'.freeze
10
- INCOMPLETE_MESSAGE = 'incomplete'.freeze
11
- MIGRATION_RUNNING = {up: 'running'.freeze, down: 'reverting'.freeze}.freeze
12
- MIGRATION_DONE = {up: 'migrated'.freeze, down: 'reverted'.freeze}.freeze
8
+ STATUS_TABLE_FORMAT = '%-10s %-20s %s'
9
+ SEPARATOR = '--------------------------------------------------'
10
+ FILE_MISSING = '**** file missing ****'
11
+ STATUS_TABLE_HEADER = ['Status', 'Migration ID', 'Migration Name'].freeze
12
+ UP_MESSAGE = 'up'
13
+ DOWN_MESSAGE = 'down'
14
+ INCOMPLETE_MESSAGE = 'incomplete'
15
+ MIGRATION_RUNNING = {up: 'running', down: 'reverting'}.freeze
16
+ MIGRATION_DONE = {up: 'migrated', down: 'reverted'}.freeze
13
17
 
14
18
  def initialize(options = {})
15
19
  @silenced = options[:silenced] || !!ENV['MIGRATIONS_SILENCED']
@@ -253,8 +253,10 @@ module ActiveGraph::Node
253
253
 
254
254
  def relationship_corresponding_rel(relationship, direction, target_class)
255
255
  self.class.associations.find do |_key, assoc|
256
- assoc.relationship_class_name == relationship.class.name ||
257
- (assoc.relationship_type == relationship.type.to_sym && assoc.target_class == target_class && assoc.direction == direction)
256
+ assoc.direction == direction && (
257
+ assoc.relationship_class_name == relationship.class.name ||
258
+ (assoc.relationship_type == relationship.type.to_sym && assoc.target_class == target_class)
259
+ )
258
260
  end
259
261
  end
260
262
 
@@ -58,6 +58,7 @@ module ActiveGraph
58
58
  def process_string(str)
59
59
  head, rest = str.split('.', 2)
60
60
  k, length = head.split('*', -2)
61
+ length = {max: length} if length
61
62
  add_nested(k.to_sym, rest, length)
62
63
  end
63
64
 
@@ -68,7 +68,7 @@ module ActiveGraph
68
68
 
69
69
  def init_associations(node, element)
70
70
  element.each_key { |key| node.association_proxy(key).init_cache }
71
- node.association_proxy(element.name).init_cache if element.rel_length == ''
71
+ node.association_proxy(element.name).init_cache if element.rel_length && element.rel_length[:max] == ''
72
72
  end
73
73
 
74
74
  def cache_and_init(node, element)
@@ -157,14 +157,8 @@ module ActiveGraph
157
157
  end
158
158
 
159
159
  def relationship_part(association, path_name, rel_length)
160
- if rel_length
161
- rel_name = nil
162
- length = {max: rel_length}
163
- else
164
- rel_name = escape("#{path_name}_rel")
165
- length = nil
166
- end
167
- "#{association.arrow_cypher(rel_name, {}, false, false, length)}(#{escape(path_name)})"
160
+ rel_name = escape("#{path_name}_rel") unless rel_length
161
+ "#{association.arrow_cypher(rel_name, {}, false, false, rel_length)}(#{escape(path_name)})"
168
162
  end
169
163
 
170
164
  def chain
@@ -22,6 +22,7 @@ module ActiveGraph
22
22
  class << self
23
23
  def for_clause(clause, arg, model, *args)
24
24
  method_to_call = "for_#{clause}_clause"
25
+ return unless respond_to?(method_to_call)
25
26
 
26
27
  send(method_to_call, arg, model, *args)
27
28
  end
@@ -112,8 +113,6 @@ module ActiveGraph
112
113
  default = [Link.new(clause, arg, *args)]
113
114
 
114
115
  Link.for_clause(clause, arg, model, *args) || default
115
- rescue NoMethodError
116
- default
117
116
  end
118
117
 
119
118
  def converted_keys(model, arg)
@@ -49,31 +49,20 @@ module ActiveGraph
49
49
  # Deletes the relationships between all nodes for the last step in the QueryProxy chain and replaces them with relationships to the given nodes.
50
50
  # Executed in the database, callbacks will not be run.
51
51
  def replace_with(node_or_nodes)
52
- node_hash = idify_hash(node_or_nodes)
52
+ node_or_nodes = Array(node_or_nodes).map { |arg| arg.is_a?(ActiveGraph::Node) ? arg : @model.find(arg) }
53
53
  original_ids = self.pluck(:id)
54
- new_nodes = add_rels(node_hash, original_ids)
55
- delete_rels_for_nodes(original_ids - node_hash.keys)
56
- new_nodes | node_hash.values
54
+ delete_rels_for_nodes(original_ids, node_or_nodes.collect(&:id))
55
+ add_rels(node_or_nodes, original_ids)
57
56
  end
58
57
 
59
- def idify_hash(args)
60
- Array(args).reject(&:blank?).flatten.each_with_object({}).with_index do |(arg, hash), inx|
61
- if arg.is_a?(Integer) || arg.is_a?(String)
62
- hash[arg.to_i] = @model.find(arg)
63
- else
64
- key = arg.persisted? ? arg.id : "tmp_#{inx}"
65
- hash[key] = arg
66
- end
67
- end
68
- end
69
-
70
- def add_rels(node_hash, original_ids)
71
- (node_hash.keys - original_ids).map do |id|
72
- node_hash[id] if _create_relation_or_defer(node_hash[id])
58
+ def add_rels(node_or_nodes, original_ids)
59
+ node_or_nodes.map do |obj|
60
+ obj if original_ids.include?(obj.id) || _create_relation_or_defer(obj)
73
61
  end.compact
74
62
  end
75
63
 
76
- def delete_rels_for_nodes(ids)
64
+ def delete_rels_for_nodes(original_ids, new_ids)
65
+ ids = original_ids.select { |id| !new_ids.include?(id) }
77
66
  return unless ids.present?
78
67
  if association.dependent
79
68
  start_object.public_send("dependent_#{association.dependent}_callback", association, ids)
@@ -28,7 +28,7 @@ module ActiveGraph
28
28
  def validate_each(record, attribute, value)
29
29
  return unless found(record, attribute, value).exists?
30
30
 
31
- record.errors.add(attribute, :taken, options.except(:case_sensitive, :scope).merge(value: value))
31
+ record.errors.add(attribute, :taken, **options.except(:case_sensitive, :scope).merge(value: value))
32
32
  end
33
33
 
34
34
  def found(record, attribute, value)
@@ -69,6 +69,33 @@ module ActiveGraph::Shared
69
69
  end
70
70
  end
71
71
 
72
+ class BigDecimalConverter < BaseConverter
73
+ class << self
74
+ def convert_type
75
+ BigDecimal
76
+ end
77
+
78
+ def db_type
79
+ String
80
+ end
81
+
82
+ def to_db(value)
83
+ case value
84
+ when Rational
85
+ value.to_f.to_d
86
+ when respond_to?(:to_d)
87
+ value.to_d
88
+ else
89
+ BigDecimal(value.to_s)
90
+ end.to_s
91
+ end
92
+
93
+ def to_ruby(value)
94
+ value.to_d
95
+ end
96
+ end
97
+ end
98
+
72
99
  class StringConverter < BaseConverter
73
100
  class << self
74
101
  def convert_type
@@ -5,9 +5,8 @@ require 'active_graph/migration'
5
5
  if !defined?(Rails) && !Rake::Task.task_defined?('environment')
6
6
  desc 'Run a script against the database to perform system-wide changes'
7
7
  task :environment do
8
- require 'active_graph/session_manager'
9
8
  require 'ostruct'
10
- neo4j_url = ENV['NEO4J_URL'] || 'http://localhost:7474'
9
+ neo4j_url = ENV['NEO4J_URL'] || 'bolt://localhost:7687'
11
10
  $LOAD_PATH.unshift File.dirname('./')
12
11
  ActiveGraph::Base.on_establish_driver do
13
12
  Neo4j::Driver::GraphDatabase.driver(neo4j_url)
@@ -8,13 +8,16 @@ module ActiveGraph
8
8
  def close
9
9
  success
10
10
  super
11
- after_commit_registry.each(&:call) unless @failure
12
11
  end
13
12
 
14
13
  def after_commit(&block)
15
14
  after_commit_registry << block
16
15
  end
17
16
 
17
+ def apply_callbacks
18
+ after_commit_registry.each(&:call) unless @failure
19
+ end
20
+
18
21
  private
19
22
 
20
23
  def after_commit_registry
@@ -43,7 +43,7 @@ module ActiveGraph
43
43
  session.send(method, **config) do |tx|
44
44
  self.tx = tx
45
45
  checked_yield(tx, &block)
46
- end
46
+ end.tap { tx.apply_callbacks }
47
47
  end
48
48
 
49
49
  def checked_yield(tx)
@@ -1,3 +1,3 @@
1
1
  module ActiveGraph
2
- VERSION = '10.0.0'
2
+ VERSION = '10.1.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activegraph
3
3
  version: !ruby/object:Gem::Version
4
- version: 10.0.0
4
+ version: 10.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andreas Ronge, Brian Underwood, Chris Grigg, Heinrich Klobuczek
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-07 00:00:00.000000000 Z
11
+ date: 2021-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "!="
46
46
  - !ruby/object:Gem::Version
47
- version: 1.3.0
47
+ version: 1.8.8
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "!="
53
53
  - !ruby/object:Gem::Version
54
- version: 1.3.0
54
+ version: 1.8.8
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: orm_adapter
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 0.5.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: sorted_set
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: guard
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -128,14 +142,14 @@ dependencies:
128
142
  requirements:
129
143
  - - "~>"
130
144
  - !ruby/object:Gem::Version
131
- version: 1.7.0
145
+ version: 1.7.4
132
146
  type: :development
133
147
  prerelease: false
134
148
  version_requirements: !ruby/object:Gem::Requirement
135
149
  requirements:
136
150
  - - "~>"
137
151
  - !ruby/object:Gem::Version
138
- version: 1.7.0
152
+ version: 1.7.4
139
153
  - !ruby/object:Gem::Dependency
140
154
  name: os
141
155
  requirement: !ruby/object:Gem::Requirement
@@ -234,6 +248,20 @@ dependencies:
234
248
  - - ">="
235
249
  - !ruby/object:Gem::Version
236
250
  version: '0'
251
+ - !ruby/object:Gem::Dependency
252
+ name: rspec
253
+ requirement: !ruby/object:Gem::Requirement
254
+ requirements:
255
+ - - "<"
256
+ - !ruby/object:Gem::Version
257
+ version: '3.10'
258
+ type: :development
259
+ prerelease: false
260
+ version_requirements: !ruby/object:Gem::Requirement
261
+ requirements:
262
+ - - "<"
263
+ - !ruby/object:Gem::Version
264
+ version: '3.10'
237
265
  description: 'A Neo4j OGM (Object-Graph-Mapper) for Ruby heavily inspired by ActiveRecord.
238
266
 
239
267
  '
@@ -260,7 +288,6 @@ files:
260
288
  - lib/active_graph/class_arguments.rb
261
289
  - lib/active_graph/config.rb
262
290
  - lib/active_graph/core.rb
263
- - lib/active_graph/core/connection_failed_error.rb
264
291
  - lib/active_graph/core/cypher_error.rb
265
292
  - lib/active_graph/core/entity.rb
266
293
  - lib/active_graph/core/instrumentable.rb
@@ -394,7 +421,7 @@ metadata:
394
421
  changelog_uri: https://github.com/neo4jrb/activegraph/blob/master/CHANGELOG.md
395
422
  source_code_uri: https://github.com/neo4jrb/activegraph/
396
423
  bug_tracker_uri: https://github.com/neo4jrb/activegraph/issues
397
- post_install_message:
424
+ post_install_message:
398
425
  rdoc_options:
399
426
  - "--quiet"
400
427
  - "--title"
@@ -416,8 +443,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
416
443
  - !ruby/object:Gem::Version
417
444
  version: '0'
418
445
  requirements: []
419
- rubygems_version: 3.1.2
420
- signing_key:
446
+ rubygems_version: 3.2.22
447
+ signing_key:
421
448
  specification_version: 4
422
449
  summary: A graph database for Ruby
423
450
  test_files: []
@@ -1,6 +0,0 @@
1
- module ActiveGraph
2
- module Core
3
- class ConnectionFailedError < StandardError;
4
- end
5
- end
6
- end