Skip to content

Commit 685e7ea

Browse files
committed
Patched to not send ROLLBACK after RESET
1 parent e725fdd commit 685e7ea

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

neo4j/v1/api.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -440,13 +440,19 @@ def rollback_transaction(self):
440440
"""
441441
if not self.has_transaction():
442442
raise TransactionError("No transaction to rollback")
443-
self._transaction = None
443+
self._destroy_transaction()
444444
rollback_result = self.__rollback__()
445445
try:
446446
rollback_result.consume()
447447
except ServiceUnavailable:
448448
pass
449449

450+
def reset(self):
451+
""" Reset the session.
452+
"""
453+
self._destroy_transaction()
454+
self._connection.reset()
455+
450456
def _run_transaction(self, access_mode, unit_of_work, *args, **kwargs):
451457
if not callable(unit_of_work):
452458
raise TypeError("Unit of work is not callable")
@@ -640,10 +646,11 @@ def close(self):
640646
self.success = False
641647
raise
642648
finally:
643-
if self.success:
644-
self.session.commit_transaction()
645-
else:
646-
self.session.rollback_transaction()
649+
if self.session.has_transaction():
650+
if self.success:
651+
self.session.commit_transaction()
652+
else:
653+
self.session.rollback_transaction()
647654
self._closed = True
648655
self.on_close()
649656

neo4j/v1/result.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def on_footer(metadata):
6565

6666
def on_failure(metadata):
6767
# Called on execution failure.
68-
self.session._connection.reset()
68+
self.session.reset()
6969
on_footer(metadata)
7070
raise CypherError.hydrate(**metadata)
7171

0 commit comments

Comments
 (0)