Skip to content
Permalink
Browse files
feat(db_api): raise exception with message for executemany() (#595)
  • Loading branch information
IlyaFaer committed Nov 16, 2021
1 parent 828df62 commit 95908f67e81554858060f0831d10ff05d149fbba
Showing with 5 additions and 5 deletions.
  1. +4 −4 google/cloud/spanner_dbapi/cursor.py
  2. +1 −1 tests/unit/spanner_dbapi/test_cursor.py
@@ -160,9 +160,9 @@ def _do_batch_update(self, transaction, statements, many_result_set):
many_result_set.add_iter(res)

if status.code == ABORTED:
raise Aborted(status.details)
raise Aborted(status.message)
elif status.code != OK:
raise OperationalError(status.details)
raise OperationalError(status.message)

def execute(self, sql, args=None):
"""Prepares and executes a Spanner database operation.
@@ -302,9 +302,9 @@ def executemany(self, operation, seq_of_params):

if status.code == ABORTED:
self.connection._transaction = None
raise Aborted(status.details)
raise Aborted(status.message)
elif status.code != OK:
raise OperationalError(status.details)
raise OperationalError(status.message)
break
except Aborted:
self.connection.retry_transaction()
@@ -506,7 +506,7 @@ def test_executemany_insert_batch_failed(self):

transaction = mock.Mock(committed=False, rolled_back=False)
transaction.batch_update = mock.Mock(
return_value=(mock.Mock(code=UNKNOWN, details=err_details), [])
return_value=(mock.Mock(code=UNKNOWN, message=err_details), [])
)

with mock.patch(

0 comments on commit 95908f6

Please sign in to comment.