activegraph 10.0.0 → 10.0.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: e434fda5c1ab2cf1ad9d3d859cec6fc31d7b076fefcf3ead00dd5890849436a1
4
+ data.tar.gz: 1d0827473f9f6c0e6000fd0da3175f6721c1e11d146734b58d9a3c216502b973
5
5
  SHA512:
6
- metadata.gz: ec40cecc16c133c065672a3aa37360c304bba5cf24fe430dda7a789885262a7b239b798a7998b6d96b34ba8d05d5d0376c134dc829d6db0800e392fb740c0ec7
7
- data.tar.gz: 9f7fc129cf6916cdf69373ebb789ff7bc5f6c38c675d3e51403c4b0e6e7135a9649cfb2f3f754634507979a371de2a6a16f8670c765e38a016627c21f04e8535
6
+ metadata.gz: d260e538a8121c313d08a51893a773ba2e7e6d7c6f0cf9e1a99f2f28da656c5192779e408f02cb7c8f399e9dbe427ed67ff6df5cf2f406a727ebb2259549c113
7
+ data.tar.gz: 40b4a2bbdc71d888447f9b2c057cdb3d0c5b5f75f783e6a61fa04defc8916908e7dc3aee2f09c8261bd9e851c67c270b1eef920fff1039cdaa68d4a023291dff
@@ -3,6 +3,14 @@ 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.0.1] 2020-07-26
7
+
8
+ ## Fixed
9
+
10
+ - fixed incorrect id comparison, which could result in lost relationships (https://github.com/neo4jrb/activegraph/issues/1611)
11
+ - brought back BigDecimalConverter
12
+ - fixed rails template (Thanks @ekampp)
13
+
6
14
  ## [10.0.0] 2020-07-06
7
15
 
8
16
  - neo4j 4.0 support (default database only)
@@ -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)
@@ -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
@@ -1,3 +1,3 @@
1
1
  module ActiveGraph
2
- VERSION = '10.0.0'
2
+ VERSION = '10.0.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.0.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: 2020-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -394,7 +394,7 @@ metadata:
394
394
  changelog_uri: https://github.com/neo4jrb/activegraph/blob/master/CHANGELOG.md
395
395
  source_code_uri: https://github.com/neo4jrb/activegraph/
396
396
  bug_tracker_uri: https://github.com/neo4jrb/activegraph/issues
397
- post_install_message:
397
+ post_install_message:
398
398
  rdoc_options:
399
399
  - "--quiet"
400
400
  - "--title"
@@ -417,7 +417,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
417
417
  version: '0'
418
418
  requirements: []
419
419
  rubygems_version: 3.1.2
420
- signing_key:
420
+ signing_key:
421
421
  specification_version: 4
422
422
  summary: A graph database for Ruby
423
423
  test_files: []