neo4j-core 6.0.0.alpha.2 → 6.0.0.alpha.5
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 +4 -4
- data/Gemfile +1 -0
- data/lib/neo4j-core/query.rb +6 -2
- data/lib/neo4j-core/version.rb +1 -1
- data/lib/neo4j-embedded/embedded_impermanent_session.rb +0 -1
- data/lib/neo4j-server/cypher_transaction.rb +6 -1
- data/lib/neo4j/core/cypher_session.rb +10 -5
- data/lib/neo4j/core/cypher_session/adaptors.rb +18 -5
- data/lib/neo4j/core/cypher_session/adaptors/embedded.rb +4 -0
- data/lib/neo4j/core/cypher_session/adaptors/http.rb +37 -9
- data/lib/neo4j/core/cypher_session/responses/http.rb +6 -2
- data/lib/neo4j/core/cypher_session/result.rb +3 -3
- data/lib/neo4j/core/node.rb +3 -0
- data/lib/neo4j/transaction.rb +24 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da1d3afa114538d40feb6d6765112f282c13ebee
|
4
|
+
data.tar.gz: fe9f7472deaddd1123e62ca73a02ed3ec70431b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36fa2080886b9b51eb29ec518399153474e4f113c7530ff137a55453397d7c3ec1f3407178d1d3ff3d28b4aacf85c0ea5740f47e646d1945cce524233c48946d
|
7
|
+
data.tar.gz: 94a3b1aadca366cdf2485de538fe0b6fc95e570f811ee8415b4826a6e4ab17d0a896b46e99f8f4d4f1ef253dba8afba65d37d64606ee5c1c6bb2405262771c9b
|
data/Gemfile
CHANGED
data/lib/neo4j-core/query.rb
CHANGED
@@ -232,9 +232,13 @@ module Neo4j
|
|
232
232
|
cypher = to_cypher
|
233
233
|
pretty_cypher = to_cypher(pretty: true) if self.class.pretty_cypher
|
234
234
|
|
235
|
-
@response = @session.
|
235
|
+
@response = if @session.is_a?(::Neo4j::Core::CypherSession)
|
236
|
+
@session.query(self)
|
237
|
+
else
|
238
|
+
@session._query(cypher, merge_params, context: @options[:context], pretty_cypher: pretty_cypher)
|
239
|
+
end
|
236
240
|
|
237
|
-
(
|
241
|
+
(!@response.respond_to?(:error?) || !response.error?) ? @response : @response.raise_cypher_error
|
238
242
|
end
|
239
243
|
|
240
244
|
def match_nodes(hash, optional_match = false)
|
data/lib/neo4j-core/version.rb
CHANGED
@@ -9,7 +9,6 @@ module Neo4j
|
|
9
9
|
class EmbeddedImpermanentSession < EmbeddedSession
|
10
10
|
def start
|
11
11
|
fail Error, 'Embedded Neo4j db is already running' if running?
|
12
|
-
puts 'Start test impermanent embedded Neo4j db'
|
13
12
|
@graph_db = Java::OrgNeo4jTest::TestGraphDatabaseFactory.new.newImpermanentDatabase
|
14
13
|
Neo4j::Session._notify_listeners(:session_available, self)
|
15
14
|
end
|
@@ -73,12 +73,17 @@ module Neo4j
|
|
73
73
|
cypher_response.set_data(first_result)
|
74
74
|
else
|
75
75
|
first_error = response.body[:errors].first
|
76
|
-
|
76
|
+
tx_cleanup!(first_error)
|
77
77
|
cypher_response.set_error(first_error)
|
78
78
|
end
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
+
def tx_cleanup!(first_error)
|
83
|
+
autoclosed!
|
84
|
+
mark_expired if first_error[:message].match(/Unrecognized transaction id/)
|
85
|
+
end
|
86
|
+
|
82
87
|
def empty_response
|
83
88
|
OpenStruct.new(status: 200, body: '')
|
84
89
|
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'neo4j/core/cypher_session/adaptors/http'
|
2
1
|
|
3
2
|
module Neo4j
|
4
3
|
module Core
|
@@ -14,13 +13,19 @@ module Neo4j
|
|
14
13
|
%w(
|
15
14
|
query
|
16
15
|
queries
|
16
|
+
|
17
17
|
start_transaction
|
18
18
|
end_transaction
|
19
|
+
transaction
|
20
|
+
transaction_started?
|
21
|
+
|
19
22
|
version
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
23
|
+
|
24
|
+
indexes_for_label
|
25
|
+
uniqueness_constraints_for_label
|
26
|
+
).each do |method, &_block|
|
27
|
+
define_method(method) do |*args, &block|
|
28
|
+
@adaptor.send(method, *args, &block)
|
24
29
|
end
|
25
30
|
end
|
26
31
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'neo4j/core/cypher_session'
|
1
2
|
require 'neo4j/core/instrumentable'
|
2
3
|
|
3
4
|
module Neo4j
|
@@ -42,10 +43,8 @@ module Neo4j
|
|
42
43
|
end
|
43
44
|
end
|
44
45
|
|
45
|
-
def query(
|
46
|
-
queries
|
47
|
-
append(cypher, parameters)
|
48
|
-
end[0]
|
46
|
+
def query(*args)
|
47
|
+
queries { append(*args) }[0]
|
49
48
|
end
|
50
49
|
|
51
50
|
def queries(&block)
|
@@ -68,10 +67,24 @@ module Neo4j
|
|
68
67
|
fail '#end_transaction not implemented!'
|
69
68
|
end
|
70
69
|
|
70
|
+
def transaction_started?(*_args)
|
71
|
+
fail '#transaction_started? not implemented!'
|
72
|
+
end
|
73
|
+
|
71
74
|
def version(*_args)
|
72
75
|
fail '#version not implemented!'
|
73
76
|
end
|
74
77
|
|
78
|
+
# Schema inspection methods
|
79
|
+
def indexes_for_label(*_args)
|
80
|
+
fail '#indexes_for_label not implemented!'
|
81
|
+
end
|
82
|
+
|
83
|
+
def uniqueness_constraints_for_label(*_args)
|
84
|
+
fail '#uniqueness_constraints_for_label not implemented!'
|
85
|
+
end
|
86
|
+
|
87
|
+
|
75
88
|
# Uses #start_transaction and #end_transaction to allow
|
76
89
|
# execution of queries within a block to be part of a
|
77
90
|
# full transaction
|
@@ -80,7 +93,7 @@ module Neo4j
|
|
80
93
|
|
81
94
|
yield
|
82
95
|
ensure
|
83
|
-
end_transaction
|
96
|
+
end_transaction if transaction_started?
|
84
97
|
end
|
85
98
|
|
86
99
|
EMPTY = ''
|
@@ -34,7 +34,8 @@ module Neo4j
|
|
34
34
|
# context option not implemented
|
35
35
|
self.class.instrument_queries(queries)
|
36
36
|
|
37
|
-
url = full_transaction_url
|
37
|
+
return unless url = full_transaction_url
|
38
|
+
|
38
39
|
faraday_response = self.class.instrument_request(url, request_data) do
|
39
40
|
@connection.post(url, request_data)
|
40
41
|
end
|
@@ -64,14 +65,43 @@ module Neo4j
|
|
64
65
|
@transaction_state = :close_requested
|
65
66
|
query_set([])
|
66
67
|
@transaction_state = nil
|
68
|
+
@transaction_id = nil
|
67
69
|
|
68
70
|
true
|
69
71
|
end
|
70
72
|
|
73
|
+
def transaction_started?
|
74
|
+
!!@transaction_id
|
75
|
+
end
|
76
|
+
|
71
77
|
def version
|
72
78
|
@version ||= @connection.get(db_data_url).body[:neo4j_version]
|
73
79
|
end
|
74
80
|
|
81
|
+
# Schema inspection methods
|
82
|
+
def indexes_for_label(label)
|
83
|
+
url = db_data_url + "schema/index/#{label}"
|
84
|
+
response = @connection.get(url)
|
85
|
+
|
86
|
+
if response.body && response.body[0]
|
87
|
+
response.body[0][:property_keys].map(&:to_sym)
|
88
|
+
else
|
89
|
+
[]
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def uniqueness_constraints_for_label(label)
|
94
|
+
url = db_data_url + "schema/constraint/#{label}/uniqueness"
|
95
|
+
response = @connection.get(url)
|
96
|
+
|
97
|
+
if response.body && response.body[0]
|
98
|
+
response.body[0][:property_keys].map(&:to_sym)
|
99
|
+
else
|
100
|
+
[]
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
|
75
105
|
instrument(:request, 'neo4j.core.http.request', %w(url body)) do |_, start, finish, _id, payload|
|
76
106
|
ms = (finish - start) * 1000
|
77
107
|
|
@@ -89,14 +119,12 @@ module Neo4j
|
|
89
119
|
end
|
90
120
|
|
91
121
|
def full_transaction_url
|
92
|
-
path =
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
db_data_url + 'transaction' + path
|
122
|
+
path = ''
|
123
|
+
path << "/#{@transaction_id}" if [:open, :close_requested].include?(@transaction_state)
|
124
|
+
path << '/commit' if [nil, :close_requested].include?(@transaction_state)
|
125
|
+
path = nil if @transaction_state == :close_requested && !@transaction_id
|
126
|
+
|
127
|
+
db_data_url + 'transaction' + path if path
|
100
128
|
end
|
101
129
|
|
102
130
|
def db_data_url
|
@@ -89,8 +89,12 @@ module Neo4j
|
|
89
89
|
end
|
90
90
|
|
91
91
|
def validate_faraday_response!(faraday_response)
|
92
|
-
if error = faraday_response.body[:errors][0]
|
93
|
-
|
92
|
+
if faraday_response.body.is_a?(Hash) && error = faraday_response.body[:errors][0]
|
93
|
+
error = <<-ERROR
|
94
|
+
Request to: #{ANSI::BOLD}#{faraday_response.env.url}#{ANSI::CLEAR}
|
95
|
+
#{ANSI::CYAN}#{error[:code]}#{ANSI::CLEAR}: #{error[:message]}
|
96
|
+
ERROR
|
97
|
+
fail CypherError, error
|
94
98
|
end
|
95
99
|
|
96
100
|
return if (200..299).include?(status = faraday_response.status)
|
@@ -11,7 +11,7 @@ module Neo4j
|
|
11
11
|
def initialize(columns, rows)
|
12
12
|
@columns = columns.map(&:to_sym)
|
13
13
|
@rows = rows
|
14
|
-
@struct_class = Struct.new(*@columns)
|
14
|
+
@struct_class = Struct.new(:index, *@columns)
|
15
15
|
end
|
16
16
|
|
17
17
|
include Enumerable
|
@@ -23,8 +23,8 @@ module Neo4j
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def structs
|
26
|
-
@structs ||= rows.map do |row|
|
27
|
-
@struct_class.new(*row)
|
26
|
+
@structs ||= rows.each_with_index.map do |row, index|
|
27
|
+
@struct_class.new(index, *row)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
data/lib/neo4j/core/node.rb
CHANGED
data/lib/neo4j/transaction.rb
CHANGED
@@ -21,6 +21,18 @@ module Neo4j
|
|
21
21
|
end
|
22
22
|
alias_method :failure?, :failed?
|
23
23
|
|
24
|
+
def autoclosed!
|
25
|
+
@autoclosed = true if transient_failures_autoclose?
|
26
|
+
end
|
27
|
+
|
28
|
+
def transient_failures_autoclose?
|
29
|
+
Neo4j::Session.current.version >= '2.2.6'
|
30
|
+
end
|
31
|
+
|
32
|
+
def autoclosed?
|
33
|
+
!!@autoclosed
|
34
|
+
end
|
35
|
+
|
24
36
|
def mark_expired
|
25
37
|
@expired = true
|
26
38
|
end
|
@@ -61,7 +73,18 @@ module Neo4j
|
|
61
73
|
return if @pushed_nested >= 0
|
62
74
|
fail "Can't commit transaction, already committed" if @pushed_nested < -1
|
63
75
|
Neo4j::Transaction.unregister(self)
|
64
|
-
|
76
|
+
post_close!
|
77
|
+
end
|
78
|
+
|
79
|
+
private
|
80
|
+
|
81
|
+
def post_close!
|
82
|
+
return if autoclosed?
|
83
|
+
if failed?
|
84
|
+
delete
|
85
|
+
else
|
86
|
+
commit
|
87
|
+
end
|
65
88
|
end
|
66
89
|
end
|
67
90
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: neo4j-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.0.0.alpha.
|
4
|
+
version: 6.0.0.alpha.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andreas Ronge, Chris Grigg, Brian Underwood
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -325,7 +325,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
325
325
|
version: 1.3.1
|
326
326
|
requirements: []
|
327
327
|
rubyforge_project:
|
328
|
-
rubygems_version: 2.4.
|
328
|
+
rubygems_version: 2.4.5.1
|
329
329
|
signing_key:
|
330
330
|
specification_version: 4
|
331
331
|
summary: A basic library to work with the graph database Neo4j.
|