Skip to content

Commit

Permalink
update bindings logic and fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xiazcy committed Aug 8, 2024
1 parent 500a0a1 commit 46b895b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,12 @@ def submit_async(self, message, bindings=None, request_options=None):
conn = self._pool.get(True)
if request_options:
message.fields.update({token: request_options[token] for token in TokensV4
if token in request_options})
if token in request_options and token != 'bindings'})
if 'bindings' in request_options:
if 'bindings' in message.fields:
message.fields['bindings'].update(request_options['bindings'])
else:
message.fields['bindings'] = request_options['bindings']
if 'params' in request_options:
if 'bindings' in message.fields:
message.fields['bindings'].update(request_options['params'])
Expand Down
11 changes: 8 additions & 3 deletions gremlin-python/src/main/python/tests/driver/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ def test_client_gremlin_lang_request_options_with_binding(client):
request_opts['bindings'] = {'y': 4}
result_set = client.submit('g.V(y).values("name")', request_options=request_opts)
assert result_set.all().result()[0] == 'josh'
result_set = client.submit('g.V(z).values("name")', bindings={'z': 5}, request_options=request_opts)
assert result_set.all().result()[0] == 'ripple'


def test_iterate_result_set(client):
Expand Down Expand Up @@ -366,8 +368,9 @@ def thread_run(tr, result_list):
def test_client_gremlin_lang_with_short(client):
g = GraphTraversalSource(Graph(), TraversalStrategies())
t = g.with_('language', 'gremlin-lang').V().has('age', short(16)).count()
request_opts = DriverRemoteConnection.extract_request_options(t.gremlin_lang)
message = create_basic_request_message(t)
result_set = client.submit(message)
result_set = client.submit(message, request_options=request_opts)
results = []
for result in result_set:
results += result
Expand All @@ -377,8 +380,9 @@ def test_client_gremlin_lang_with_short(client):
def test_client_gremlin_lang_with_long(client):
g = GraphTraversalSource(Graph(), TraversalStrategies())
t = g.V().has('age', long(851401972585122)).count()
request_opts = DriverRemoteConnection.extract_request_options(t.gremlin_lang)
message = create_basic_request_message(t)
result_set = client.submit(message)
result_set = client.submit(message, request_options=request_opts)
results = []
for result in result_set:
results += result
Expand All @@ -388,8 +392,9 @@ def test_client_gremlin_lang_with_long(client):
def test_client_gremlin_lang_with_bigint(client):
g = GraphTraversalSource(Graph(), TraversalStrategies())
t = g.with_('language', 'gremlin-lang').V().has('age', bigint(0x1000_0000_0000_0000_0000)).count()
request_opts = DriverRemoteConnection.extract_request_options(t.gremlin_lang)
message = create_basic_request_message(t)
result_set = client.submit(message)
result_set = client.submit(message, request_options=request_opts)
results = []
for result in result_set:
results += result
Expand Down

0 comments on commit 46b895b

Please sign in to comment.