Skip to content

Commit

Permalink
Patched to not send ROLLBACK after RESET
Browse files Browse the repository at this point in the history
  • Loading branch information
technige committed Jun 27, 2018
1 parent e725fdd commit 685e7ea
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
17 changes: 12 additions & 5 deletions neo4j/v1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,13 +440,19 @@ def rollback_transaction(self):
"""
if not self.has_transaction():
raise TransactionError("No transaction to rollback")
self._transaction = None
self._destroy_transaction()
rollback_result = self.__rollback__()
try:
rollback_result.consume()
except ServiceUnavailable:
pass

def reset(self):
""" Reset the session.
"""
self._destroy_transaction()
self._connection.reset()

def _run_transaction(self, access_mode, unit_of_work, *args, **kwargs):
if not callable(unit_of_work):
raise TypeError("Unit of work is not callable")
Expand Down Expand Up @@ -640,10 +646,11 @@ def close(self):
self.success = False
raise
finally:
if self.success:
self.session.commit_transaction()
else:
self.session.rollback_transaction()
if self.session.has_transaction():
if self.success:
self.session.commit_transaction()
else:
self.session.rollback_transaction()
self._closed = True
self.on_close()

Expand Down
2 changes: 1 addition & 1 deletion neo4j/v1/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def on_footer(metadata):

def on_failure(metadata):
# Called on execution failure.
self.session._connection.reset()
self.session.reset()
on_footer(metadata)
raise CypherError.hydrate(**metadata)

Expand Down

0 comments on commit 685e7ea

Please sign in to comment.