neo4j 9.6.2 → 10.0.0.pre.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +0 -13
- data/CONTRIBUTORS +4 -0
- data/Gemfile +2 -33
- data/lib/neo4j.rb +6 -2
- data/lib/neo4j/active_base.rb +19 -22
- data/lib/neo4j/active_node/has_n.rb +1 -1
- data/lib/neo4j/active_node/labels.rb +1 -11
- data/lib/neo4j/active_node/node_wrapper.rb +1 -1
- data/lib/neo4j/active_node/query/query_proxy_methods_of_mass_updating.rb +1 -1
- data/lib/neo4j/active_rel/rel_wrapper.rb +2 -2
- data/lib/neo4j/ansi.rb +14 -0
- data/lib/neo4j/core.rb +14 -0
- data/lib/neo4j/core/connection_failed_error.rb +6 -0
- data/lib/neo4j/core/cypher_error.rb +37 -0
- data/lib/neo4j/core/driver.rb +83 -0
- data/lib/neo4j/core/has_uri.rb +63 -0
- data/lib/neo4j/core/instrumentable.rb +36 -0
- data/lib/neo4j/core/label.rb +158 -0
- data/lib/neo4j/core/logging.rb +44 -0
- data/lib/neo4j/core/node.rb +23 -0
- data/lib/neo4j/core/querable.rb +88 -0
- data/lib/neo4j/core/query.rb +487 -0
- data/lib/neo4j/core/query_builder.rb +32 -0
- data/lib/neo4j/core/query_clauses.rb +727 -0
- data/lib/neo4j/core/query_find_in_batches.rb +49 -0
- data/lib/neo4j/core/relationship.rb +13 -0
- data/lib/neo4j/core/responses.rb +50 -0
- data/lib/neo4j/core/result.rb +33 -0
- data/lib/neo4j/core/schema.rb +30 -0
- data/lib/neo4j/core/schema_errors.rb +12 -0
- data/lib/neo4j/core/wrappable.rb +30 -0
- data/lib/neo4j/migration.rb +2 -2
- data/lib/neo4j/migrations/base.rb +1 -1
- data/lib/neo4j/model_schema.rb +2 -2
- data/lib/neo4j/railtie.rb +8 -52
- data/lib/neo4j/schema/operation.rb +1 -1
- data/lib/neo4j/shared.rb +1 -1
- data/lib/neo4j/shared/property.rb +1 -1
- data/lib/neo4j/tasks/migration.rake +5 -4
- data/lib/neo4j/transaction.rb +137 -0
- data/lib/neo4j/version.rb +1 -1
- data/neo4j.gemspec +5 -5
- metadata +59 -26
- data/bin/neo4j-jars +0 -33
- data/lib/neo4j/active_base/session_registry.rb +0 -12
- data/lib/neo4j/session_manager.rb +0 -78
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ad62d7a9aef94c37ee1bee3ec34b94aa539240ddaf7fb3d0bd6081685569d70
|
4
|
+
data.tar.gz: b1f6a1a5bb2acb59ddaa364141e80aaad3fcf6d978fdf4c0b4301b934abd27bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6af43cca75d102ee54a0869dc72fbe2ea3337c49999591d0072caaf9bbceac05b8de0dfb092d8adf5a8d1f3b86a3527344883ca06b3909ed4d88017be19b30e
|
7
|
+
data.tar.gz: '08b1201082c9bf09557a5cc890e4c92b7b2c9fa1e7bcbfb05851369f8ff6df42dadb84761a47cfb8cf164d976b7976beff404177a56d1b13e12a9d1dcc8f80e5'
|
data/CHANGELOG.md
CHANGED
@@ -3,19 +3,6 @@ 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.6.2] 2020-04-09
|
7
|
-
|
8
|
-
## Fixes
|
9
|
-
|
10
|
-
- Perform separate tranactions around schema-load and migrations-update
|
11
|
-
to allow the seabolt driver to load schemas (#1599)
|
12
|
-
|
13
|
-
## [9.6.1] 2019-12-18
|
14
|
-
|
15
|
-
## Fixed
|
16
|
-
|
17
|
-
- Fixed duplicate records with with_associations on QueryProxy. (#1576)
|
18
|
-
|
19
6
|
## [9.6.0] 2019-09-3
|
20
7
|
|
21
8
|
## Added
|
data/CONTRIBUTORS
CHANGED
data/Gemfile
CHANGED
@@ -2,47 +2,16 @@ source 'http://rubygems.org'
|
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
# gem 'neo4j-
|
6
|
-
|
7
|
-
branch = ENV['NEO4J_CORE_BRANCH'] || ENV['TRAVIS_PULL_REQUEST_BRANCH'] || ENV['TRAVIS_BRANCH']
|
8
|
-
slug = !ENV['TRAVIS_PULL_REQUEST_SLUG'].to_s.empty? ? ENV['TRAVIS_PULL_REQUEST_SLUG'] : ENV['TRAVIS_REPO_SLUG']
|
9
|
-
if branch
|
10
|
-
command = "curl --head https://github.com/#{slug}-core/tree/#{branch} | head -1"
|
11
|
-
result = `#{command}`
|
12
|
-
if result =~ /200 OK/
|
13
|
-
gem 'neo4j-core', github: "#{slug}-core", branch: branch
|
14
|
-
else
|
15
|
-
gem 'neo4j-core', github: 'neo4jrb/neo4j-core', branch: 'master'
|
16
|
-
end
|
17
|
-
elsif ENV['USE_LOCAL_CORE']
|
18
|
-
gem 'neo4j-core', path: '../neo4j-core'
|
19
|
-
else
|
20
|
-
gem 'neo4j-core'
|
21
|
-
end
|
22
|
-
|
23
|
-
# gem 'active_attr', github: 'neo4jrb/active_attr', branch: 'performance'
|
24
|
-
# gem 'active_attr', path: '../active_attr'
|
5
|
+
# gem 'neo4j-ruby-driver', path: '../neo4j-ruby-driver'
|
25
6
|
|
26
7
|
gem 'listen', '< 3.1'
|
27
8
|
|
28
9
|
active_model_version = ENV['ACTIVE_MODEL_VERSION']
|
29
10
|
gem 'activemodel', "~> #{active_model_version}" if active_model_version
|
30
11
|
|
31
|
-
if RUBY_VERSION.to_f < 2.2
|
32
|
-
gem 'activemodel', '~> 4.2'
|
33
|
-
gem 'activesupport', '~> 4.2'
|
34
|
-
gem 'railties', '~> 4.2'
|
35
|
-
end
|
36
|
-
|
37
12
|
group 'test' do
|
38
13
|
gem 'coveralls', require: false
|
39
|
-
|
40
|
-
gem 'term-ansicolor', '< 1.4'
|
41
|
-
gem 'tins', '< 1.7'
|
42
|
-
gem 'overcommit', '< 0.35.0'
|
43
|
-
else
|
44
|
-
gem 'overcommit'
|
45
|
-
end
|
14
|
+
gem 'overcommit'
|
46
15
|
gem 'codecov', require: false
|
47
16
|
gem 'simplecov', require: false
|
48
17
|
gem 'simplecov-html', require: false
|
data/lib/neo4j.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
require 'forwardable'
|
2
2
|
require 'neo4j/version'
|
3
3
|
|
4
|
-
require 'neo4j
|
4
|
+
require 'neo4j/core'
|
5
5
|
require 'neo4j/core/query_ext' # From this gem
|
6
6
|
|
7
7
|
require 'neo4j/active_base'
|
8
8
|
require 'neo4j/model_schema'
|
9
|
-
require 'neo4j/active_base/session_registry'
|
10
9
|
|
11
10
|
require 'active_model'
|
12
11
|
require 'active_support/concern'
|
13
12
|
require 'active_support/core_ext/class/attribute.rb'
|
14
13
|
require 'active_support/core_ext/class/subclasses.rb'
|
14
|
+
require 'active_support/core_ext/module/attribute_accessors'
|
15
15
|
require 'json'
|
16
16
|
|
17
17
|
require 'neo4j/errors'
|
@@ -97,6 +97,10 @@ require 'neo4j/active_node/query'
|
|
97
97
|
require 'neo4j/active_node/scope'
|
98
98
|
require 'neo4j/active_node'
|
99
99
|
|
100
|
+
require 'active_support/concern'
|
101
|
+
require 'neo4j/core/cypher_error'
|
102
|
+
require 'neo4j/core/schema_errors'
|
103
|
+
|
100
104
|
module Neo4j
|
101
105
|
extend ActiveSupport::Autoload
|
102
106
|
autoload :Migrations
|
data/lib/neo4j/active_base.rb
CHANGED
@@ -4,8 +4,8 @@ module Neo4j
|
|
4
4
|
module ActiveBase
|
5
5
|
class << self
|
6
6
|
# private?
|
7
|
-
def
|
8
|
-
(
|
7
|
+
def current_driver
|
8
|
+
(@driver ||= establish_session).tap do |session|
|
9
9
|
fail 'No session defined!' if session.nil?
|
10
10
|
end
|
11
11
|
end
|
@@ -15,57 +15,59 @@ module Neo4j
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def establish_session
|
18
|
-
|
18
|
+
@establish_session_block.call if @establish_session_block
|
19
|
+
end
|
20
|
+
|
21
|
+
def new_driver(url, options = {})
|
22
|
+
verbose_query_logs = Neo4j::Config.fetch(:verbose_query_logs, false)
|
23
|
+
Neo4j::Core::Driver
|
24
|
+
.new(url, options.merge(verbose_query_logs: verbose_query_logs))
|
19
25
|
end
|
20
26
|
|
21
27
|
def current_transaction_or_session
|
22
|
-
current_transaction ||
|
28
|
+
current_transaction || Transaction
|
23
29
|
end
|
24
30
|
|
25
31
|
def query(*args)
|
26
32
|
current_transaction_or_session.query(*args)
|
27
33
|
end
|
28
34
|
|
29
|
-
# Should support setting
|
30
|
-
def
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
def current_adaptor=(adaptor)
|
35
|
-
self.current_session = Neo4j::Core::CypherSession.new(adaptor)
|
35
|
+
# Should support setting driver via config options
|
36
|
+
def driver=(driver)
|
37
|
+
@driver = driver
|
36
38
|
end
|
37
39
|
|
38
40
|
def run_transaction(run_in_tx = true)
|
39
|
-
Neo4j::Transaction.run(
|
41
|
+
Neo4j::Transaction.run(current_driver, run_in_tx) do |tx|
|
40
42
|
yield tx
|
41
43
|
end
|
42
44
|
end
|
43
45
|
|
44
46
|
def new_transaction
|
45
47
|
validate_model_schema!
|
46
|
-
Neo4j::Transaction.new
|
48
|
+
Neo4j::Transaction.new
|
47
49
|
end
|
48
50
|
|
49
51
|
def new_query(options = {})
|
50
52
|
validate_model_schema!
|
51
|
-
Neo4j::Core::Query.new({session:
|
53
|
+
Neo4j::Core::Query.new({session: current_driver}.merge(options))
|
52
54
|
end
|
53
55
|
|
54
56
|
def magic_query(*args)
|
55
57
|
if args.empty? || args.map(&:class) == [Hash]
|
56
58
|
ActiveBase.new_query(*args)
|
57
59
|
else
|
58
|
-
ActiveBase.
|
60
|
+
ActiveBase.current_driver.query(*args)
|
59
61
|
end
|
60
62
|
end
|
61
63
|
|
62
64
|
def current_transaction
|
63
65
|
validate_model_schema!
|
64
|
-
Neo4j::Transaction.
|
66
|
+
Neo4j::Transaction.root
|
65
67
|
end
|
66
68
|
|
67
69
|
def label_object(label_name)
|
68
|
-
Neo4j::Core::Label.new(label_name
|
70
|
+
Neo4j::Core::Label.new(label_name)
|
69
71
|
end
|
70
72
|
|
71
73
|
def logger
|
@@ -77,11 +79,6 @@ module Neo4j
|
|
77
79
|
def validate_model_schema!
|
78
80
|
Neo4j::ModelSchema.validate_model_schema! unless Neo4j::Migrations.currently_running_migrations
|
79
81
|
end
|
80
|
-
|
81
|
-
def make_session_wrap!(session)
|
82
|
-
session.adaptor.instance_variable_get('@options')[:wrap_level] = :proc
|
83
|
-
session
|
84
|
-
end
|
85
82
|
end
|
86
83
|
end
|
87
84
|
end
|
@@ -103,7 +103,7 @@ module Neo4j::ActiveNode
|
|
103
103
|
|
104
104
|
def add_to_cache(object, rel = nil)
|
105
105
|
(@cached_rels ||= []) << rel if rel
|
106
|
-
(@cached_result ||= [])
|
106
|
+
(@cached_result ||= []) << object
|
107
107
|
end
|
108
108
|
|
109
109
|
def rels
|
@@ -41,11 +41,6 @@ module Neo4j
|
|
41
41
|
@_persisted_obj.labels.uniq!
|
42
42
|
end
|
43
43
|
|
44
|
-
# Remove this method in 9.0.0
|
45
|
-
def add_label(*_labels)
|
46
|
-
fail 'add_label has been removed in favor of `add_labels`'
|
47
|
-
end
|
48
|
-
|
49
44
|
# Removes one or more labels
|
50
45
|
# Be careful, don't remove the label representing the Ruby class.
|
51
46
|
# @see Neo4j-core
|
@@ -56,11 +51,6 @@ module Neo4j
|
|
56
51
|
labels.each(&@_persisted_obj.labels.method(:delete))
|
57
52
|
end
|
58
53
|
|
59
|
-
# Remove this method in 9.0.0
|
60
|
-
def remove_label(*_labels)
|
61
|
-
fail 'remove_label has been removed in favor of `remove_labels`'
|
62
|
-
end
|
63
|
-
|
64
54
|
def self._wrapped_classes
|
65
55
|
WRAPPED_CLASSES
|
66
56
|
end
|
@@ -141,7 +131,7 @@ module Neo4j
|
|
141
131
|
|
142
132
|
# @return [Neo4j::Label] the label for this class
|
143
133
|
def mapped_label
|
144
|
-
Neo4j::Core::Label.new(mapped_label_name
|
134
|
+
Neo4j::Core::Label.new(mapped_label_name)
|
145
135
|
end
|
146
136
|
|
147
137
|
def base_class
|
@@ -27,7 +27,7 @@ module Neo4j
|
|
27
27
|
query_with_target(identifier) do |target|
|
28
28
|
begin
|
29
29
|
self.query.with(target).optional_match("(#{target})-[#{target}_rel]-()").delete("#{target}, #{target}_rel").exec
|
30
|
-
rescue Neo4j::Core::
|
30
|
+
rescue Neo4j::Core::CypherError # <=- Seems hacky
|
31
31
|
self.query.delete(target).exec
|
32
32
|
end
|
33
33
|
clear_source_object_cache
|
@@ -3,7 +3,7 @@ require 'neo4j/core/relationship'
|
|
3
3
|
wrapping_proc = proc do |relationship|
|
4
4
|
Neo4j::RelWrapping.wrapper(relationship)
|
5
5
|
end
|
6
|
-
Neo4j::
|
6
|
+
Neo4j::Driver::Types::Relationship.wrapper_callback(wrapping_proc)
|
7
7
|
|
8
8
|
module Neo4j
|
9
9
|
module RelWrapping
|
@@ -24,7 +24,7 @@ module Neo4j
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def class_from_type(rel_type)
|
27
|
-
Neo4j::ActiveRel::Types::WRAPPED_CLASSES[rel_type] || Neo4j::ActiveRel::Types::WRAPPED_CLASSES[rel_type] = rel_type.to_s.camelize
|
27
|
+
Neo4j::ActiveRel::Types::WRAPPED_CLASSES[rel_type] || Neo4j::ActiveRel::Types::WRAPPED_CLASSES[rel_type] = rel_type.to_s.downcase.camelize
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
data/lib/neo4j/ansi.rb
ADDED
data/lib/neo4j/core.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'neo4j/transaction'
|
2
|
+
require 'neo4j/core/instrumentable'
|
3
|
+
require 'neo4j/core/query'
|
4
|
+
require 'neo4j/core/driver'
|
5
|
+
require 'neo4j/core/responses'
|
6
|
+
|
7
|
+
require 'neo4j_ruby_driver'
|
8
|
+
require 'neo4j/core/wrappable'
|
9
|
+
require 'neo4j/core/node'
|
10
|
+
require 'neo4j/core/relationship'
|
11
|
+
|
12
|
+
Neo4j::Driver::Types::Entity.include Neo4j::Core::Wrappable
|
13
|
+
Neo4j::Driver::Types::Node.prepend Neo4j::Core::Node
|
14
|
+
Neo4j::Driver::Types::Relationship.include Neo4j::Core::Relationship
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Neo4j
|
2
|
+
module Core
|
3
|
+
class CypherError < StandardError
|
4
|
+
attr_reader :code, :original_message, :stack_trace
|
5
|
+
|
6
|
+
def initialize(code = nil, original_message = nil, stack_trace = nil)
|
7
|
+
@code = code
|
8
|
+
@original_message = original_message
|
9
|
+
@stack_trace = stack_trace
|
10
|
+
|
11
|
+
msg = <<-ERROR
|
12
|
+
Cypher error:
|
13
|
+
#{ANSI::CYAN}#{code}#{ANSI::CLEAR}: #{original_message}
|
14
|
+
#{stack_trace}
|
15
|
+
ERROR
|
16
|
+
super(msg)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.new_from(code, message, stack_trace = nil)
|
20
|
+
error_class_from(code).new(code, message, stack_trace)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.error_class_from(code)
|
24
|
+
case code
|
25
|
+
when /(ConstraintValidationFailed|ConstraintViolation)/
|
26
|
+
SchemaErrors::ConstraintValidationFailedError
|
27
|
+
when /IndexAlreadyExists/
|
28
|
+
SchemaErrors::IndexAlreadyExistsError
|
29
|
+
when /ConstraintAlreadyExists/ # ?????
|
30
|
+
SchemaErrors::ConstraintAlreadyExistsError
|
31
|
+
else
|
32
|
+
CypherError
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'active_support/core_ext/module/attribute_accessors'
|
2
|
+
require 'neo4j/core/logging'
|
3
|
+
require 'neo4j/core/has_uri'
|
4
|
+
|
5
|
+
module Neo4j
|
6
|
+
module Core
|
7
|
+
class Driver
|
8
|
+
include HasUri
|
9
|
+
|
10
|
+
USER_AGENT_STRING = "neo4j-gem/#{::Neo4j::VERSION} (https://github.com/neo4jrb/neo4j)"
|
11
|
+
|
12
|
+
cattr_reader :singleton
|
13
|
+
attr_accessor :wrap_level
|
14
|
+
attr_reader :options, :driver
|
15
|
+
delegate :close, to: :driver
|
16
|
+
|
17
|
+
@@mutex = Mutex.new
|
18
|
+
at_exit do
|
19
|
+
close
|
20
|
+
end
|
21
|
+
|
22
|
+
default_url('bolt://neo4:neo4j@localhost:7687')
|
23
|
+
|
24
|
+
validate_uri do |uri|
|
25
|
+
uri.scheme == 'bolt'
|
26
|
+
end
|
27
|
+
|
28
|
+
class << self
|
29
|
+
def singleton=(driver)
|
30
|
+
@@mutex.synchronize do
|
31
|
+
singleton&.close
|
32
|
+
class_variable_set(:@@singleton, driver)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def new_instance(url)
|
37
|
+
uri = URI(url)
|
38
|
+
user = uri.user
|
39
|
+
password = uri.password
|
40
|
+
auth_token = if user
|
41
|
+
Neo4j::Driver::AuthTokens.basic(user, password)
|
42
|
+
else
|
43
|
+
Neo4j::Driver::AuthTokens.none
|
44
|
+
end
|
45
|
+
Neo4j::Driver::GraphDatabase.driver(url, auth_token)
|
46
|
+
end
|
47
|
+
|
48
|
+
def close
|
49
|
+
singleton&.close
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def initialize(url, options = {})
|
54
|
+
self.url = url
|
55
|
+
@driver = self.class.new_instance(url)
|
56
|
+
self.class.singleton = self
|
57
|
+
@options = options
|
58
|
+
end
|
59
|
+
|
60
|
+
def logger
|
61
|
+
return @logger if @logger
|
62
|
+
|
63
|
+
@logger = if @options[:logger]
|
64
|
+
@options[:logger]
|
65
|
+
else
|
66
|
+
Logger.new(logger_location).tap do |logger|
|
67
|
+
logger.level = logger_level
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
private
|
73
|
+
|
74
|
+
def logger_location
|
75
|
+
@options[:logger_location] || STDOUT
|
76
|
+
end
|
77
|
+
|
78
|
+
def logger_level
|
79
|
+
@options[:logger_level] || Logger::WARN
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|