neo4j-ruby-driver 0.3.4 → 1.7.0

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: 285f1e745b1c40e78643541afbda39871b35e261b80f2a11c5a1282339dd9a73
4
- data.tar.gz: 22fde4ee4e1a5ccb729063a1d4bf96ebd51af261c73e9739325fa4817d9109d3
3
+ metadata.gz: d33153e299b755a419d12e6977650124965789923b7faedaddfa78dfde1bd6d1
4
+ data.tar.gz: abdaeef0e7c8dc83c6dc38d052e10630836a0cb3c9999976f8a1fed5b616a650
5
5
  SHA512:
6
- metadata.gz: 9c044349f323e3aad1215ccbd28b9a4f9f750ae6e0ca0e3ecdaeb4601122fb016169552ab47e4de63b753a0b77eff29c37f4a1b1e56fa9d4486132f9efa599fc
7
- data.tar.gz: dcc9281e5572ca88fb7a8073f1ab7a145209d9a7c055af62c0b985e87e3eeac59a5e5e6fc8beb533c6cf9b1ee217a8538d49460010f0d849d7243588987dc860
6
+ metadata.gz: e72296857ec72dd8d624098be60d5567a775fcbd4a0d3c6fcc931314072114c7ffcc8d33ac1a4f72dd8983ec9548d5da88609d7e1319b3223cc7450459f8e13c
7
+ data.tar.gz: e9a45e37d1332e0391230900949891945ee5e1182c89d6b63d87fe5992659fa14f2ef4bd6bfe80c42c2aa3daaa620013fbbef273141070341c78beccd8a37e34
data/README.md CHANGED
@@ -72,12 +72,11 @@ FFI based same as above but with driver variable set:
72
72
  To run the tests the following tools need to be installed:
73
73
 
74
74
  $ brew install python
75
- $ wget https://bootstrap.pypa.io/get-pip.py && python3 get-pip.py --user
76
- $ python3 -m pip install --user git+https://github.com/klobuczek/boltkit@1.3#egg=boltkit
77
- $ neoctrl-install -e 4.0.0 servers
78
- $ neoctrl-configure servers/neo4j-enterprise-4.0.0 dbms.directories.import=
79
- $ neoctrl-set-initial-password password servers/neo4j-enterprise-4.0.0
80
- $ neoctrl-start servers/neo4j-enterprise-4.0.0
75
+ $ pip3 install --user git+https://github.com/klobuczek/boltkit@1.3#egg=boltkit
76
+ $ neoctrl-install -e 4.0.2 servers
77
+ $ neoctrl-configure servers/neo4j-enterprise-4.0.2 dbms.directories.import= dbms.default_listen_address=::
78
+ $ neoctrl-set-initial-password password servers/neo4j-enterprise-4.0.2
79
+ $ neoctrl-start servers/neo4j-enterprise-4.0.2
81
80
 
82
81
  ## Contributing
83
82
 
@@ -54,3 +54,7 @@ module Neo4j
54
54
  end
55
55
 
56
56
  Loader.load
57
+
58
+ Neo4j::Driver::Record = Neo4j::Driver::Internal::InternalRecord
59
+ Neo4j::Driver::StatementResult = Neo4j::Driver::Internal::InternalStatementResult
60
+ Neo4j::Driver::Transaction = Neo4j::Driver::Internal::ExplicitTransaction
@@ -44,7 +44,7 @@ module Neo4j
44
44
  scheme = (uris.map(&method(:URI)).map(&:scheme) - VALID_ROUTING_SCHEMES).first
45
45
  return unless scheme
46
46
  raise ArgumentError,
47
- "Illegal URI scheme, expected URI scheme '#{scheme}' to be among [#{VALID_ROUTING_SCHEMES.join ', '}]"
47
+ "Illegal URI scheme, expected URI scheme '#{scheme}' to be among '[#{VALID_ROUTING_SCHEMES.join ', '}]'"
48
48
  end
49
49
  end
50
50
  end
@@ -30,6 +30,7 @@ module Neo4j
30
30
  )
31
31
  end
32
32
  set_bookmarks(:set_run_bookmarks, boomarks_holder.bookmarks)
33
+ set_config(:set_run, config)
33
34
  register(run_handler, Bolt::Connection.load_run_request(bolt_connection))
34
35
  register(pull_handler, Bolt::Connection.load_pull_request(bolt_connection, -1))
35
36
  flush
@@ -42,6 +43,7 @@ module Neo4j
42
43
  def begin(bookmarks, config, begin_handler)
43
44
  check_error Bolt::Connection.clear_begin(bolt_connection)
44
45
  set_bookmarks(:set_begin_bookmarks, bookmarks)
46
+ set_config(:set_begin, config)
45
47
  register(begin_handler, Bolt::Connection.load_begin_request(bolt_connection))
46
48
  end
47
49
 
@@ -82,6 +84,21 @@ module Neo4j
82
84
  Value::ValueAdapter.to_neo(value, bookmarks)
83
85
  check_error Bolt::Connection.send(method, bolt_connection, value)
84
86
  end
87
+
88
+ def set_config(method_prefix, config)
89
+ return unless config
90
+ config.each do |key, value|
91
+ case key
92
+ when :timeout
93
+ check_error Bolt::Connection.send("#{method_prefix}_tx_timeout", bolt_connection,
94
+ DurationNormalizer.milliseconds(value))
95
+ when :metadata
96
+ bolt_value = Bolt::Value.create
97
+ Value::ValueAdapter.to_neo(bolt_value, value)
98
+ check_error Bolt::Connection.send("#{method_prefix}_tx_metadata", bolt_connection, bolt_value)
99
+ end
100
+ end
101
+ end
85
102
  end
86
103
  end
87
104
  end
@@ -49,7 +49,7 @@ module Neo4j
49
49
  )
50
50
  end
51
51
  end
52
- check_error Bolt::Config.set_user_agent(bolt_config, 'seabolt-cmake/1.7')
52
+ check_error Bolt::Config.set_user_agent(bolt_config, "neo4j-ruby-driver #{Neo4j::Driver::VERSION}")
53
53
  bolt_config
54
54
  end
55
55
 
@@ -21,7 +21,7 @@ module Neo4j
21
21
  def finalize
22
22
  return if @finished
23
23
  super
24
- @statement_keys = Value::ValueAdapter.to_ruby(Bolt::Connection.field_names(bolt_connection))
24
+ @statement_keys = Value::ValueAdapter.to_ruby(Bolt::Connection.field_names(bolt_connection)).map(&:to_sym)
25
25
  metadata = Value::ValueAdapter.to_ruby(Bolt::Connection.metadata(bolt_connection))
26
26
  @result_available_after = metadata[:result_available_after] || metadata[:t_first]
27
27
  end
@@ -4,7 +4,7 @@ module Neo4j
4
4
  module Driver
5
5
  module Internal
6
6
  class InternalRecord
7
- attr_reader :values
7
+ attr_reader :keys, :values
8
8
  delegate :first, to: :values
9
9
 
10
10
  def initialize(keys, values)
@@ -13,9 +13,13 @@ module Neo4j
13
13
  end
14
14
 
15
15
  def [](key)
16
- field_index = key.is_a?(Integer) ? key : @keys.index(key.to_s)
16
+ field_index = key.is_a?(Integer) ? key : @keys.index(key.to_sym)
17
17
  @values[field_index] if field_index
18
18
  end
19
+
20
+ def to_h
21
+ keys.zip(values).to_h
22
+ end
19
23
  end
20
24
  end
21
25
  end
@@ -18,7 +18,7 @@ module Neo4j
18
18
  @retry_logic = retry_logic
19
19
  end
20
20
 
21
- def run(statement, parameters = {}, config = nil)
21
+ def run(statement, parameters = {}, config = {})
22
22
  ensure_session_is_open
23
23
  ensure_no_open_tx_before_running_query
24
24
  acquire_connection(@mode)
@@ -27,11 +27,11 @@ module Neo4j
27
27
  )
28
28
  end
29
29
 
30
- def read_transaction(config = nil, &block)
30
+ def read_transaction(**config, &block)
31
31
  transaction(Neo4j::Driver::AccessMode::READ, config, &block)
32
32
  end
33
33
 
34
- def write_transaction(config = nil, &block)
34
+ def write_transaction(**config, &block)
35
35
  transaction(Neo4j::Driver::AccessMode::WRITE, config, &block)
36
36
  end
37
37
 
@@ -49,11 +49,8 @@ module Neo4j
49
49
  @connection&.release
50
50
  end
51
51
 
52
- def begin_transaction(mode = @mode, config = nil)
53
- ensure_session_is_open
54
- ensure_no_open_tx_before_starting_tx
55
- acquire_connection(mode)
56
- @transaction = ExplicitTransaction.new(@connection, self).begin(bookmarks, config)
52
+ def begin_transaction(**config)
53
+ private_begin_transaction(@mode, config)
57
54
  end
58
55
 
59
56
  def last_bookmark
@@ -66,9 +63,16 @@ module Neo4j
66
63
 
67
64
  private
68
65
 
69
- def transaction(mode, config = nil)
66
+ def private_begin_transaction(mode, config)
67
+ ensure_session_is_open
68
+ ensure_no_open_tx_before_starting_tx
69
+ acquire_connection(mode)
70
+ @transaction = ExplicitTransaction.new(@connection, self).begin(bookmarks, config)
71
+ end
72
+
73
+ def transaction(mode, config)
70
74
  @retry_logic.retry do
71
- tx = begin_transaction(mode, config)
75
+ tx = private_begin_transaction(mode, config)
72
76
  result = yield tx
73
77
  tx.success
74
78
  result
@@ -80,7 +84,7 @@ module Neo4j
80
84
  end
81
85
  end
82
86
 
83
- def acquire_connection(mode = @mode)
87
+ def acquire_connection(mode)
84
88
  # make sure previous result is fully consumed and connection is released back to the pool
85
89
  @result&.failure
86
90
 
@@ -90,7 +94,7 @@ module Neo4j
90
94
  # 3) previous result failed and error has been consumed
91
95
 
92
96
  raise Exceptions::IllegalStateException, 'Existing open connection detected' if @connection&.open?
93
- @connection = @connection_provider.acquire_connection(@mode)
97
+ @connection = @connection_provider.acquire_connection(mode)
94
98
  end
95
99
 
96
100
  def close_transaction_and_release_connection
@@ -11,6 +11,10 @@ module Neo4j
11
11
  @id = id
12
12
  @properties = properties
13
13
  end
14
+
15
+ def ==(other)
16
+ self.class == other.class && id == other.id
17
+ end
14
18
  end
15
19
  end
16
20
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Neo4j
4
4
  module Driver
5
- VERSION = '0.3.4'
5
+ VERSION = '1.7.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neo4j-ruby-driver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Heinrich Klobuczek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-12 00:00:00.000000000 Z
11
+ date: 2020-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport