Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(db_api): raise exception with message for executemany() #595

Merged
merged 11 commits into from Nov 16, 2021
8 changes: 4 additions & 4 deletions google/cloud/spanner_dbapi/cursor.py
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
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