activegraph 12.0.0.beta.6 → 12.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6f10f61337255f2e1e68ba9e4a7d06c5cad602ee9d94fd3258d6c4437f40f64d
4
- data.tar.gz: e7525d5641cb10951fb92e973259a6ec88ca83d529070065b8cd75491791cf02
3
+ metadata.gz: 631a772ff4cad538ff9390a07f910d0369c341e0bc6e8e35957521a1ec16cba4
4
+ data.tar.gz: 45daf82de8e8bce83260c8245f8988e897dcd70dc35fda742247525e1e7ab38b
5
5
  SHA512:
6
- metadata.gz: 7f56d37e271db3e850cf861384afa46e7cf2427656ef9392982bdb6f46834499db15eeb943e3d6f6149af23d902d719bfd7ea07b601dab9032f022768e1f67a2
7
- data.tar.gz: 2c452170b87d7fbe6e83ce87965bd2c30ef671edcd6083b819f1160f2175a9aee0d82d3187eed86e0e6ac8174f5883a5541be4a4d8b72b6154e69ace9714e348
6
+ metadata.gz: a571949dd06e7289914e90ba4d8507793b73b48531a7d8d17a83a15c145e901e73380783ba3521da52a6bcc93056ec290969b007d3a455588699c720e8103774
7
+ data.tar.gz: d501ed3dfed4a833b93608de5f883721a93277752719abda0d1c9ba734fc1c62acebba0fd88a037cb1f446432bee00992d83a66904ce3a741c7941442a159532
data/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@ 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
+ ## [12.0.0] (2026-08-16)
7
+
8
+ ### Changed
9
+ - Use the driver-native Neo4j::Driver::Types::Duration instead of ActiveSupport::Duration
10
+
11
+ ### Added
12
+ - Type converted for ActiveSupport::Duration to Neo4j::Driver::Types::Duration for backward compatibility. The converter is lossy if fractional units are used in ActiveSupport::Duration.
13
+
14
+ ### Fixed
15
+ - Adapt to neo4j-ruby-driver 6.2.1
16
+
17
+ ## [12.0.0.beta.7] (2026-03-19)
18
+
19
+ ### Fixed
20
+ - Improved rollback handling in nested transactions to ensure the result of the block is returned even when a rollback is triggered.
21
+
6
22
  ## [12.0.0.beta.6] 2026-03-18
7
23
 
8
24
  ## Added
@@ -238,12 +254,6 @@ This project adheres to [Semantic Versioning](http://semver.org/).
238
254
 
239
255
  - Micro-optimizations which help when dealing with a lot of data (thanks @jgaskins / see #1490)
240
256
 
241
- ## [9.1.8] 2018-03-27
242
-
243
- ## Fixed
244
-
245
- - Micro-optimizations which help when dealing with a lot of data (thanks @jgaskins / see #1490)
246
-
247
257
  ## [9.1.7] 2018-03-27
248
258
 
249
259
  ## Fixed
data/activegraph.gemspec CHANGED
@@ -33,7 +33,7 @@ DESCRIPTION
33
33
  s.add_dependency('activemodel')
34
34
  s.add_dependency('benchmark')
35
35
  s.add_dependency('i18n', '!= 1.8.8') # https://github.com/jruby/jruby/issues/6547
36
- s.add_dependency('neo4j-ruby-driver', '>= 6.0.3.alpha.0')
36
+ s.add_dependency('neo4j-ruby-driver', '~> 6.2.1.beta.4')
37
37
  s.add_dependency('orm_adapter', '>= 0.5.0')
38
38
  s.add_development_dependency('guard')
39
39
  s.add_development_dependency('guard-rspec')
@@ -13,7 +13,7 @@ module ActiveGraph
13
13
 
14
14
  def each(&block)
15
15
  store if wrap? # TODO: why? This is preventing streaming
16
- @records&.each(&block) || super
16
+ @wrapped_records&.each(&block) || super
17
17
  end
18
18
 
19
19
  ## To avoid to_a on Neo4j::Driver::Result as that one does not call the above block
@@ -22,13 +22,13 @@ module ActiveGraph
22
22
  end
23
23
 
24
24
  def store
25
- return if @records
25
+ return if @wrapped_records
26
26
  keys
27
- @records = []
27
+ @wrapped_records = []
28
28
  # TODO: implement 'each' without block parameter
29
29
  method(:each).super_method.call do |record|
30
30
  record.wrap = wrap?
31
- @records << record
31
+ @wrapped_records << record
32
32
  end
33
33
  end
34
34
  end
@@ -59,8 +59,12 @@ module ActiveGraph
59
59
  @major ||= version.segments.first
60
60
  end
61
61
 
62
+ # Neo4j 2026.07+ renamed the uniqueness constraint types
63
+ # (UNIQUENESS -> NODE_PROPERTY_UNIQUENESS, RELATIONSHIP_UNIQUENESS ->
64
+ # RELATIONSHIP_PROPERTY_UNIQUENESS); accept both the old and new names.
62
65
  def constraint_filter(record)
63
- %w[UNIQUENESS RELATIONSHIP_UNIQUENESS RELATIONSHIP_PROPERTY_EXISTENCE NODE_PROPERTY_EXISTENCE NODE_KEY RELATIONSHIP_KEY].include?(record[:type])
66
+ %w[UNIQUENESS NODE_PROPERTY_UNIQUENESS RELATIONSHIP_UNIQUENESS RELATIONSHIP_PROPERTY_UNIQUENESS
67
+ RELATIONSHIP_PROPERTY_EXISTENCE NODE_PROPERTY_EXISTENCE NODE_KEY RELATIONSHIP_KEY].include?(record[:type])
64
68
  end
65
69
 
66
70
  def index_cypher(label, properties)
@@ -20,7 +20,7 @@ module ActiveGraph
20
20
  count = count_relations(relation_query)
21
21
  output "Indexing #{count} #{old_name}s into #{new_name}..."
22
22
  while count > 0
23
- relation_query.create("(a)-[r2:`#{new_name}`]->(b)").set('r2 = r').with(:r).limit(max_per_batch).delete(:r).exec
23
+ relation_query.create("(a)-[r2:`#{new_name}`]->(b)").set('r2 = properties(r)').with(:r).limit(max_per_batch).delete(:r).exec
24
24
  count = count_relations(relation_query)
25
25
  output "... #{count} #{old_name}'s left to go.." if count > 0
26
26
  end
@@ -12,7 +12,7 @@ module ActiveGraph::Shared
12
12
  attr_reader :_persisted_obj
13
13
 
14
14
  # This list should not be statically created. All types which have converters should by type casted
15
- NEO4J_DRIVER_DATA_TYPES = [Hash, ActiveSupport::Duration, Neo4j::Driver::Types::Point,
15
+ NEO4J_DRIVER_DATA_TYPES = [Hash, Neo4j::Driver::Types::Duration, Neo4j::Driver::Types::Point,
16
16
  Neo4j::Driver::Types::OffsetTime, Neo4j::Driver::Types::LocalTime, Neo4j::Driver::Types::LocalDateTime]
17
17
 
18
18
  # TODO: Set @attribute correctly using class ActiveModel::Attribute, and after that
@@ -185,6 +185,48 @@ module ActiveGraph::Shared
185
185
  end
186
186
  end
187
187
 
188
+ # Converts ActiveSupport::Duration to/from the driver-native
189
+ # Neo4j::Driver::Types::Duration. Kept for backwards compatibility: since
190
+ # driver 6.2.1 a Neo4j duration is a Types::Duration, but models may still
191
+ # declare `type: ActiveSupport::Duration`. The mapping is field-to-field
192
+ # (parts <-> months/days/seconds/nanoseconds) and value-exact; the only soft
193
+ # spot is a fractional calendar month, which has no exact finer form and
194
+ # degrades to seconds via ActiveSupport's own rate.
195
+ class DurationConverter < BaseConverter
196
+ class << self
197
+ def convert_type
198
+ ActiveSupport::Duration
199
+ end
200
+
201
+ def db_type
202
+ Neo4j::Driver::Types::Duration
203
+ end
204
+
205
+ def to_db(value)
206
+ parts = Hash.new(0).merge(value.parts)
207
+ months_f = parts[:years] * 12 + parts[:months]
208
+ days_f = parts[:weeks] * 7 + parts[:days]
209
+ months = months_f.to_i
210
+ days = days_f.to_i
211
+ # whole calendar units stay put; fractional months/days cascade into
212
+ # seconds rather than truncating (which would lose magnitude)
213
+ seconds = parts[:hours] * 3600 + parts[:minutes] * 60 + parts[:seconds] +
214
+ (months_f - months) * ActiveSupport::Duration::SECONDS_PER_MONTH +
215
+ (days_f - days) * ActiveSupport::Duration::SECONDS_PER_DAY
216
+ Neo4j::Driver::Types::Duration.new(months, days, seconds.floor, ((seconds % 1) * 1_000_000_000).round)
217
+ end
218
+
219
+ def to_ruby(value)
220
+ return value if value.is_a?(ActiveSupport::Duration)
221
+ # map each Neo4j field back to its ActiveSupport unit, field-to-field,
222
+ # so the calendar structure survives the round trip
223
+ ActiveSupport::Duration.months(value.months) +
224
+ ActiveSupport::Duration.days(value.days) +
225
+ ActiveSupport::Duration.seconds(value.seconds + Rational(value.nanoseconds, 1_000_000_000))
226
+ end
227
+ end
228
+ end
229
+
188
230
  class BooleanConverter < BaseConverter
189
231
  FALSE_VALUES = %w(n N no No NO false False FALSE off Off OFF f F).to_set
190
232
 
@@ -1,7 +1,11 @@
1
1
  module ActiveGraph
2
2
  module Transaction
3
3
  def rollback
4
- fail ActiveGraph::Rollback
4
+ @active_graph_rolled_back = true
5
+ end
6
+
7
+ def check_rollback
8
+ fail ActiveGraph::Rollback if @active_graph_rolled_back
5
9
  end
6
10
 
7
11
  def after_commit(&block)
@@ -42,24 +42,27 @@ module ActiveGraph
42
42
  end
43
43
  end
44
44
 
45
- def run_transaction_work(session, method, **config, &block)
46
- implicit = config.delete(:implicit)
45
+ def run_transaction_work(session, method, implicit: false, **config, &block)
46
+ result = nil
47
47
  session.send(method, **config) do |tx|
48
48
  self.tx = tx
49
- block.call(tx).tap do |result|
50
- if implicit &&
51
- [Core::Result, ActiveGraph::Node::Query::QueryProxy, ActiveGraph::Core::Query]
52
- .any?(&result.method(:is_a?))
53
- result.store
54
- end
49
+ (result = block.call(tx)).tap do
50
+ store(it) if implicit
51
+ tx.check_rollback
55
52
  end
56
53
  end.tap { tx.apply_callbacks }
57
54
  rescue ActiveGraph::Rollback
58
55
  # rollbacks are silently swallowed
59
- false # to satisfy save and update conventions
56
+ result
60
57
  ensure
61
58
  self.tx = nil
62
59
  end
60
+
61
+ def store(result)
62
+ if [Core::Result, ActiveGraph::Node::Query::QueryProxy, ActiveGraph::Core::Query].any?(&result.method(:is_a?))
63
+ result.store
64
+ end
65
+ end
63
66
  end
64
67
  end
65
68
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveGraph
2
- VERSION = '12.0.0.beta.6'
2
+ VERSION = '12.0.0'
3
3
  end
data/lib/active_graph.rb CHANGED
@@ -10,6 +10,8 @@ require 'active_support/core_ext/class/attribute'
10
10
  require 'active_support/core_ext/class/subclasses'
11
11
  require 'active_support/core_ext/module/attribute_accessors'
12
12
  require 'active_support/core_ext/module/attribute_accessors_per_thread'
13
+ require 'active_support/core_ext/numeric/time'
14
+ require 'active_support/core_ext/integer/time'
13
15
  require 'active_support/core_ext/string/conversions'
14
16
  require 'active_support/inflector'
15
17
  require 'active_support/inflector/inflections'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activegraph
3
3
  version: !ruby/object:Gem::Version
4
- version: 12.0.0.beta.6
4
+ version: 12.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andreas Ronge, Brian Underwood, Chris Grigg, Heinrich Klobuczek
@@ -55,16 +55,16 @@ dependencies:
55
55
  name: neo4j-ruby-driver
56
56
  requirement: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - ">="
58
+ - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: 6.0.3.alpha.0
60
+ version: 6.2.1.beta.4
61
61
  type: :runtime
62
62
  prerelease: false
63
63
  version_requirements: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - ">="
65
+ - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: 6.0.3.alpha.0
67
+ version: 6.2.1.beta.4
68
68
  - !ruby/object:Gem::Dependency
69
69
  name: orm_adapter
70
70
  requirement: !ruby/object:Gem::Requirement
@@ -431,7 +431,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
431
431
  - !ruby/object:Gem::Version
432
432
  version: '0'
433
433
  requirements: []
434
- rubygems_version: 4.0.3
434
+ rubygems_version: 4.0.16
435
435
  specification_version: 4
436
436
  summary: A graph database for Ruby
437
437
  test_files: []