Skip to content

Commit

Permalink
feat(db_api): raise exception with message for executemany() (#595)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilya Gurov authored Nov 16, 2021
1 parent 828df62 commit 95908f6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions google/cloud/spanner_dbapi/cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/spanner_dbapi/test_cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 95908f6

Please sign in to comment.