activegraph 10.0.0.pre.beta.10 → 10.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +39 -4
- data/Gemfile +1 -2
- data/README.md +21 -17
- data/activegraph.gemspec +4 -2
- data/lib/active_graph/migrations/runner.rb +13 -9
- data/lib/active_graph/node/has_n.rb +1 -1
- data/lib/active_graph/node/labels.rb +3 -3
- data/lib/active_graph/node/persistence.rb +2 -2
- data/lib/active_graph/node/query/query_proxy.rb +1 -1
- data/lib/active_graph/node/query/query_proxy_link.rb +1 -2
- data/lib/active_graph/node/query/query_proxy_methods.rb +1 -1
- data/lib/active_graph/node/query/query_proxy_methods_of_mass_updating.rb +8 -19
- data/lib/active_graph/node/validations.rb +1 -1
- data/lib/active_graph/railtie.rb +15 -16
- data/lib/active_graph/relationship/persistence.rb +3 -3
- data/lib/active_graph/shared/attributes.rb +1 -1
- data/lib/active_graph/shared/callbacks.rb +1 -1
- data/lib/active_graph/shared/declared_properties.rb +1 -1
- data/lib/active_graph/shared/mass_assignment.rb +1 -2
- data/lib/active_graph/shared/persistence.rb +8 -8
- data/lib/active_graph/shared/property.rb +1 -1
- data/lib/active_graph/shared/type_converters.rb +27 -0
- data/lib/active_graph/tasks/migration.rake +1 -2
- data/lib/active_graph/transaction.rb +4 -1
- data/lib/active_graph/transactions.rb +1 -1
- data/lib/active_graph/version.rb +1 -1
- data/lib/rails/generators/active_graph/model/templates/migration.erb +2 -0
- metadata +42 -15
- data/lib/active_graph/core/connection_failed_error.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d9a017158867d022f2faae20f99fcbdc4196c046062e08d11bc1c77a41c48e8
|
4
|
+
data.tar.gz: 42ec5aafff7b8e5e372aefdbcf414ae9eeb1640d104ebee16a1f051cb37ac94f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6274d56abf4d330f8e29d5ebba5f788d44355eb079df9730a380ad0433899bccfbd250d89cd0d88cfe67e7e52bf8ff8e981cc34bbc668faf639d66affe724233
|
7
|
+
data.tar.gz: 0b7418a39e465ff94705b3cccc72ff41bc66a1dfe25791dbbcca07e331e6694348fefdb9bfb82139d3d90d582b90e6b48ea8defa491dd6b25dc18f233015d4ec
|
data/CHANGELOG.md
CHANGED
@@ -3,11 +3,46 @@ 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
|
6
|
+
## [10.1.0] 2021-02-05
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
-
|
8
|
+
## Added
|
9
|
+
|
10
|
+
- support for ruby 3.0.0
|
11
|
+
|
12
|
+
## [10.0.2] 2020-12-08
|
13
|
+
|
14
|
+
## Fixed
|
15
|
+
|
16
|
+
- fixed bad require (https://github.com/neo4jrb/activegraph/issues/1634)
|
17
|
+
- removed unused exception class (Thanks @joshjordan)
|
18
|
+
- prevented after_commit callbacks from being called multiple times (Thanks @joshjordan)
|
19
|
+
|
20
|
+
## [10.0.1] 2020-07-26
|
21
|
+
|
22
|
+
## Fixed
|
23
|
+
|
24
|
+
- fixed incorrect id comparison, which could result in lost relationships (https://github.com/neo4jrb/activegraph/issues/1611)
|
25
|
+
- brought back BigDecimalConverter
|
26
|
+
- fixed rails template (Thanks @ekampp)
|
27
|
+
|
28
|
+
## [10.0.0] 2020-07-06
|
29
|
+
|
30
|
+
- neo4j 4.0 support (default database only)
|
31
|
+
- dropped support for neo4j 3.3 or earlier
|
32
|
+
- full bolt support
|
33
|
+
- full causal cluster support
|
34
|
+
- removal of http support
|
35
|
+
- removal of embedded support (neo4j embedded is still supported via bolt)
|
36
|
+
- support for a neo4j ruby driver with an api of the official drivers
|
37
|
+
- discontinuation of the ``neo4j-core`` gem. Its functionality is replaced partially by ``neo4j-ruby-driver`` and
|
38
|
+
partially by ``activegraph``
|
39
|
+
- higher naming consistency with ``activerecord`` and the official ``neo4j-java-driver``
|
40
|
+
- configuration more consistent with ``activerecord``
|
41
|
+
- changed transaction API
|
42
|
+
- support for sessions with bookmarks and read and write transaction
|
43
|
+
- enforcing has one constraint on relationships
|
44
|
+
- better handling of has_many (no deletion and recreation)
|
45
|
+
- executing association callbacks on relationship deletion
|
11
46
|
|
12
47
|
## [9.6.1] 2019-12-18
|
13
48
|
|
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
@@ -11,7 +11,7 @@
|
|
11
11
|
|
12
12
|
### Documentation
|
13
13
|
|
14
|
-
All new documentation will be done via our [readthedocs](http://neo4jrb.readthedocs.org) site, though some old documentation has yet to be moved from our [wiki](https://github.com/neo4jrb/neo4j/wiki)
|
14
|
+
All new documentation will be done via our [readthedocs](http://neo4jrb.readthedocs.org) site, though some old documentation has yet to be moved from our [wiki](https://github.com/neo4jrb/neo4j/wiki)
|
15
15
|
|
16
16
|
### Contact Us
|
17
17
|
|
@@ -45,27 +45,31 @@ 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 |
|
49
|
-
|
50
|
-
| 1.9.x | Yes | No | No | No |
|
51
|
-
| 2.0.x | No | Yes | No | No |
|
52
|
-
| 2.1.x | No | Yes | Yes * | Yes |
|
53
|
-
| 2.2.x | No | No | Yes | Yes |
|
54
|
-
| 2.3.x | No | No | Yes | Yes |
|
55
|
-
|
|
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 |
|
56
59
|
|
57
60
|
`*` 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
|
58
61
|
|
59
62
|
## Neo4j feature support
|
60
63
|
|
61
|
-
| **Neo4j Feature** | v2.x | v3.x | >= v4.x | >= 8.x |
|
62
|
-
|
63
|
-
| Bolt Protocol | No | No | No | Yes |
|
64
|
-
| Auth | No | No | Yes | Yes |
|
65
|
-
| Remote Cypher | Yes | Yes | Yes | Yes |
|
66
|
-
| Transactions | Yes | Yes | Yes | Yes |
|
67
|
-
| High Availability | No | Yes | Yes | Yes |
|
68
|
-
|
|
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 |
|
69
73
|
|
70
74
|
## Documentation
|
71
75
|
|
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.
|
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", '
|
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'
|
5
|
-
SEPARATOR = '--------------------------------------------------'
|
6
|
-
FILE_MISSING = '**** file missing ****'
|
7
|
-
STATUS_TABLE_HEADER = ['Status'
|
8
|
-
UP_MESSAGE = 'up'
|
9
|
-
DOWN_MESSAGE = 'down'
|
10
|
-
INCOMPLETE_MESSAGE = 'incomplete'
|
11
|
-
MIGRATION_RUNNING = {up: 'running'
|
12
|
-
MIGRATION_DONE = {up: 'migrated'
|
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']
|
@@ -402,7 +402,7 @@ module ActiveGraph::Node
|
|
402
402
|
#
|
403
403
|
# This would define the methods: ``#vehicle``, ``#vehicle=``, and ``.vehicle``.
|
404
404
|
#
|
405
|
-
# See :ref:`#has_many <
|
405
|
+
# See :ref:`#has_many <ActiveGraph/Node/HasN/ClassMethods#has_many>` for anything
|
406
406
|
# not specified here
|
407
407
|
#
|
408
408
|
def has_one(direction, name, options = {}) # rubocop:disable Naming/PredicateName
|
@@ -21,7 +21,7 @@ module ActiveGraph
|
|
21
21
|
class RecordNotFound < ActiveGraph::RecordNotFound; end
|
22
22
|
|
23
23
|
# @return the labels
|
24
|
-
# @see
|
24
|
+
# @see ActiveGraph::Core
|
25
25
|
def labels
|
26
26
|
@_persisted_obj.labels
|
27
27
|
end
|
@@ -32,7 +32,7 @@ module ActiveGraph
|
|
32
32
|
# end
|
33
33
|
|
34
34
|
# adds one or more labels
|
35
|
-
# @see
|
35
|
+
# @see ActiveGraph::Core
|
36
36
|
def add_labels(*labels)
|
37
37
|
labels.inject(query_as(:n)) do |query, label|
|
38
38
|
query.set("n:`#{label}`")
|
@@ -43,7 +43,7 @@ module ActiveGraph
|
|
43
43
|
|
44
44
|
# Removes one or more labels
|
45
45
|
# Be careful, don't remove the label representing the Ruby class.
|
46
|
-
# @see
|
46
|
+
# @see ActiveGraph::Core
|
47
47
|
def remove_labels(*labels)
|
48
48
|
labels.inject(query_as(:n)) do |query, label|
|
49
49
|
query.remove("n:`#{label}`")
|
@@ -30,8 +30,8 @@ module ActiveGraph::Node
|
|
30
30
|
end
|
31
31
|
|
32
32
|
# Increments concurrently a numeric attribute by a centain amount
|
33
|
-
# @param [Symbol, String] name of the attribute to increment
|
34
|
-
# @param [Integer, Float] amount to increment
|
33
|
+
# @param [Symbol, String] attribute name of the attribute to increment
|
34
|
+
# @param [Integer, Float] by amount to increment
|
35
35
|
def concurrent_increment!(attribute, by = 1)
|
36
36
|
increment_by_query! query_as(:n), attribute, by
|
37
37
|
end
|
@@ -16,7 +16,7 @@ module ActiveGraph
|
|
16
16
|
attr_reader :source_object, :association, :model, :starting_query
|
17
17
|
|
18
18
|
# QueryProxy is Node's Cypher DSL. While the name might imply that it creates queries in a general sense,
|
19
|
-
# it is actually referring to <tt>ActiveGraph::Core::Query</tt>, which is a pure Ruby Cypher DSL provided by the <tt>
|
19
|
+
# it is actually referring to <tt>ActiveGraph::Core::Query</tt>, which is a pure Ruby Cypher DSL provided by the <tt>activegraph</tt> gem.
|
20
20
|
# QueryProxy provides ActiveRecord-like methods for common patterns. When it's not handling CRUD for relationships and queries, it
|
21
21
|
# provides Node's association chaining (`student.lessons.teachers.where(age: 30).hobbies`) and enjoys long walks on the
|
22
22
|
# beach.
|
@@ -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)
|
@@ -82,7 +82,7 @@ module ActiveGraph
|
|
82
82
|
|
83
83
|
alias blank? empty?
|
84
84
|
|
85
|
-
# @param [ActiveGraph::Node, ActiveGraph::Node, String] other An instance of a Neo4j.rb model, a
|
85
|
+
# @param [ActiveGraph::Node, ActiveGraph::Node, String] other An instance of a Neo4j.rb model, a core node, or a string uuid
|
86
86
|
# @param [String, Symbol] target An identifier of a link in the Cypher chain
|
87
87
|
# @return [Boolean]
|
88
88
|
def include?(other, target = nil)
|
@@ -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
|
-
|
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
|
-
|
55
|
-
|
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
|
60
|
-
|
61
|
-
if
|
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(
|
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)
|
data/lib/active_graph/railtie.rb
CHANGED
@@ -2,12 +2,13 @@ require 'active_support/notifications'
|
|
2
2
|
require 'rails/railtie'
|
3
3
|
# Need the action_dispatch railtie to have action_dispatch.rescue_responses initialized correctly
|
4
4
|
require 'action_dispatch/railtie'
|
5
|
+
require 'active_graph'
|
5
6
|
|
6
7
|
module ActiveGraph
|
7
8
|
class Railtie < ::Rails::Railtie
|
8
9
|
def empty_config
|
9
10
|
ActiveSupport::OrderedOptions.new.tap do |cfg|
|
10
|
-
cfg.driver = ActiveSupport::OrderedOptions.new
|
11
|
+
cfg.driver = ActiveSupport::OrderedOptions.new
|
11
12
|
end
|
12
13
|
end
|
13
14
|
|
@@ -58,31 +59,29 @@ module ActiveGraph
|
|
58
59
|
end
|
59
60
|
end
|
60
61
|
|
61
|
-
def setup!(
|
62
|
-
|
63
|
-
|
62
|
+
def setup!(config = empty_config)
|
63
|
+
config = final_driver_config!(config)
|
64
|
+
scheme = config.delete(:scheme) || 'bolt'
|
65
|
+
host = config.delete(:host) || 'localhost'
|
66
|
+
port = config.delete(:port) || 7687
|
67
|
+
url = config.delete(:url) || URI::Generic.build( scheme: scheme, host: host, port: port ).to_s
|
68
|
+
username = config.delete(:username)
|
69
|
+
password = config.delete(:password)
|
70
|
+
auth_token = config.delete(:auth_token)
|
64
71
|
auth_token ||= username ? Neo4j::Driver::AuthTokens.basic(username, password) : Neo4j::Driver::AuthTokens.none
|
65
72
|
register_neo4j_cypher_logging
|
66
73
|
|
67
|
-
url ||= path || default_driver_path_or_url
|
68
74
|
method = url.is_a?(Enumerable) ? :routing_driver : :driver
|
69
75
|
Neo4j::Driver::GraphDatabase.send(method, url, auth_token, config)
|
70
76
|
end
|
71
77
|
|
72
|
-
def final_driver_config!(
|
73
|
-
|
74
|
-
end
|
75
|
-
|
76
|
-
def default_driver_path_or_url
|
77
|
-
ENV['NEO4J_URL'] || ENV['NEO4J_PATH'] || 'bolt://localhost:7474'
|
78
|
+
def final_driver_config!(config)
|
79
|
+
{ url: ENV['NEO4J_URL'] }.compact.merge(config[:driver]).merge(yaml_config_data)
|
78
80
|
end
|
79
81
|
|
80
82
|
def yaml_config_data
|
81
|
-
@yaml_config_data ||=
|
82
|
-
|
83
|
-
else
|
84
|
-
{}
|
85
|
-
end
|
83
|
+
@yaml_config_data ||=
|
84
|
+
yaml_path ? YAML.load(ERB.new(yaml_path.read).result)[Rails.env].transform_keys!(&:to_sym) : {}
|
86
85
|
end
|
87
86
|
|
88
87
|
def yaml_path
|
@@ -37,8 +37,8 @@ module ActiveGraph::Relationship
|
|
37
37
|
end
|
38
38
|
|
39
39
|
# Increments concurrently a numeric attribute by a centain amount
|
40
|
-
# @param [Symbol, String] name of the attribute to increment
|
41
|
-
# @param [Integer, Float] amount to increment
|
40
|
+
# @param [Symbol, String] attribute name of the attribute to increment
|
41
|
+
# @param [Integer, Float] by amount to increment
|
42
42
|
def concurrent_increment!(attribute, by = 1)
|
43
43
|
increment_by_query! query_as(:r), attribute, by, :r
|
44
44
|
end
|
@@ -65,7 +65,7 @@ module ActiveGraph::Relationship
|
|
65
65
|
|
66
66
|
module ClassMethods
|
67
67
|
# Creates a new relationship between objects
|
68
|
-
# @param [Hash]
|
68
|
+
# @param [Hash] args the properties the new relationship should have
|
69
69
|
def create(*args)
|
70
70
|
new(*args).tap(&:save)
|
71
71
|
end
|
@@ -189,7 +189,7 @@ module ActiveGraph::Shared
|
|
189
189
|
|
190
190
|
# Assign a set of attribute definitions, used when subclassing models
|
191
191
|
#
|
192
|
-
# @param [Array<ActiveGraph::Shared::DeclaredProperties>] The Array of
|
192
|
+
# @param [Array<ActiveGraph::Shared::DeclaredProperties>] attributes The Array of
|
193
193
|
# AttributeDefinition instances
|
194
194
|
def attributes=(attributes)
|
195
195
|
@attributes = attributes
|
@@ -9,7 +9,7 @@ module ActiveGraph
|
|
9
9
|
|
10
10
|
included do
|
11
11
|
include ActiveModel::Validations::Callbacks
|
12
|
-
# after_find is triggered by the `find` method defined in lib/
|
12
|
+
# after_find is triggered by the `find` method defined in lib/active_graph/node/id_property.rb
|
13
13
|
define_model_callbacks :initialize, :find, only: :after
|
14
14
|
define_model_callbacks :create_commit, :update_commit, :destroy_commit, only: :after
|
15
15
|
define_model_callbacks :save, :create, :update, :destroy, :touch
|
@@ -75,7 +75,7 @@ module ActiveGraph::Shared
|
|
75
75
|
end.freeze
|
76
76
|
end
|
77
77
|
|
78
|
-
# During object wrapping, a props hash is built with string keys but
|
78
|
+
# During object wrapping, a props hash is built with string keys but ActiveGraph::Core provides symbols.
|
79
79
|
# Rather than a `to_s` or `symbolize_keys` during every load, we build a map of symbol-to-string
|
80
80
|
# to speed up the process. This increases memory used by the gem but reduces object allocation and GC, so it is faster
|
81
81
|
# in practice.
|
@@ -19,9 +19,8 @@ module ActiveGraph::Shared
|
|
19
19
|
# person.first_name #=> "Chris"
|
20
20
|
# person.last_name #=> "Griego"
|
21
21
|
#
|
22
|
-
# @param [Hash{#to_s => Object}, #each]
|
22
|
+
# @param [Hash{#to_s => Object}, #each] new_attributes Attributes used to
|
23
23
|
# populate the model
|
24
|
-
# @param [Hash, #[]] options Options that affect mass assignment
|
25
24
|
def assign_attributes(new_attributes = nil)
|
26
25
|
return unless new_attributes.present?
|
27
26
|
new_attributes.each do |name, value|
|
@@ -30,7 +30,7 @@ module ActiveGraph::Shared
|
|
30
30
|
# @return [Hash]
|
31
31
|
def props_for_create
|
32
32
|
inject_timestamps!
|
33
|
-
props_with_defaults = inject_defaults!(
|
33
|
+
props_with_defaults = inject_defaults!(props)
|
34
34
|
converted_props = props_for_db(props_with_defaults)
|
35
35
|
return converted_props unless self.class.respond_to?(:default_property_values)
|
36
36
|
inject_primary_key!(converted_props)
|
@@ -46,8 +46,8 @@ module ActiveGraph::Shared
|
|
46
46
|
end
|
47
47
|
|
48
48
|
# Increments a numeric attribute by a centain amount
|
49
|
-
# @param [Symbol, String] name of the attribute to increment
|
50
|
-
# @param [Integer, Float] amount to increment
|
49
|
+
# @param [Symbol, String] attribute name of the attribute to increment
|
50
|
+
# @param [Integer, Float] by amount to increment
|
51
51
|
def increment(attribute, by = 1)
|
52
52
|
self[attribute] ||= 0
|
53
53
|
self[attribute] += by
|
@@ -55,15 +55,15 @@ module ActiveGraph::Shared
|
|
55
55
|
end
|
56
56
|
|
57
57
|
# Convenience method to increment numeric attribute and #save at the same time
|
58
|
-
# @param [Symbol, String] name of the attribute to increment
|
59
|
-
# @param [Integer, Float] amount to increment
|
58
|
+
# @param [Symbol, String] attribute name of the attribute to increment
|
59
|
+
# @param [Integer, Float] by amount to increment
|
60
60
|
def increment!(attribute, by = 1)
|
61
61
|
increment(attribute, by).update_attribute(attribute, self[attribute])
|
62
62
|
end
|
63
63
|
|
64
64
|
# Increments concurrently a numeric attribute by a centain amount
|
65
|
-
# @param [Symbol, String] name of the attribute to increment
|
66
|
-
# @param [Integer, Float] amount to increment
|
65
|
+
# @param [Symbol, String] _attribute name of the attribute to increment
|
66
|
+
# @param [Integer, Float] _by amount to increment
|
67
67
|
def concurrent_increment!(_attribute, _by = 1)
|
68
68
|
fail 'not_implemented'
|
69
69
|
end
|
@@ -143,7 +143,7 @@ module ActiveGraph::Shared
|
|
143
143
|
end
|
144
144
|
|
145
145
|
# @return [Hash] all defined and none nil properties
|
146
|
-
def
|
146
|
+
def props
|
147
147
|
attributes.reject { |_, v| v.nil? }.symbolize_keys
|
148
148
|
end
|
149
149
|
|
@@ -132,7 +132,7 @@ module ActiveGraph::Shared
|
|
132
132
|
# Defines a property on the class
|
133
133
|
#
|
134
134
|
# See active_attr gem for allowed options, e.g which type
|
135
|
-
# Notice, in
|
135
|
+
# Notice, in ActiveGraph you don't have to declare properties before using them, see the ActiveGraph::Coree api.
|
136
136
|
#
|
137
137
|
# @example Without type
|
138
138
|
# class Person
|
@@ -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'] || '
|
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
|
data/lib/active_graph/version.rb
CHANGED
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.
|
4
|
+
version: 10.1.0
|
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:
|
11
|
+
date: 2021-02-06 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.
|
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.
|
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
|
@@ -126,16 +140,16 @@ dependencies:
|
|
126
140
|
name: neo4j-ruby-driver
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
128
142
|
requirements:
|
129
|
-
- - "
|
143
|
+
- - "~>"
|
130
144
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
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:
|
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"
|
@@ -412,12 +439,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
412
439
|
version: '2.5'
|
413
440
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
414
441
|
requirements:
|
415
|
-
- - "
|
442
|
+
- - ">="
|
416
443
|
- !ruby/object:Gem::Version
|
417
|
-
version:
|
444
|
+
version: '0'
|
418
445
|
requirements: []
|
419
|
-
rubygems_version: 3.
|
420
|
-
signing_key:
|
446
|
+
rubygems_version: 3.2.3
|
447
|
+
signing_key:
|
421
448
|
specification_version: 4
|
422
449
|
summary: A graph database for Ruby
|
423
450
|
test_files: []
|