Skip to content

Commit 60b3ebf

Browse files
committed
Add execute_query to MRI
1 parent ed76a81 commit 60b3ebf

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

ruby/neo4j/driver/internal/internal_driver.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,22 @@ def async_session(**session_config)
2525
InternalAsyncSession.new(new_session(**session_config))
2626
end
2727

28+
def execute_query(query, auth_token = nil, config = {}, **parameters)
29+
session_config_keys = %i[bookmarks database impersonated_user default_access_mode fetch_size]
30+
tx_config_keys = %i[timeout metadata]
31+
32+
session_config = config.slice(*session_config_keys)
33+
session_config[:auth] = auth_token if auth_token
34+
tx_config = config.slice(*tx_config_keys)
35+
36+
session(**session_config) do |session|
37+
result = session.run(query, parameters, tx_config)
38+
records = result.to_a
39+
summary = result.consume
40+
InternalEagerResult.new(records, summary)
41+
end
42+
end
43+
2844
def encrypted?
2945
assert_open!
3046
@security_plan.requires_encryption?
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module Neo4j::Driver
2+
module Internal
3+
class InternalEagerResult
4+
attr_reader :records, :summary
5+
6+
def initialize(records, summary)
7+
@records = records
8+
@summary = summary
9+
end
10+
end
11+
end
12+
end

0 commit comments

Comments
 (0)