Skip to content

Commit 95908f6

Browse files
author
Ilya Gurov
authored
feat(db_api): raise exception with message for executemany() (#595)
1 parent 828df62 commit 95908f6

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

‎google/cloud/spanner_dbapi/cursor.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ def _do_batch_update(self, transaction, statements, many_result_set):
160160
many_result_set.add_iter(res)
161161

162162
if status.code == ABORTED:
163-
raise Aborted(status.details)
163+
raise Aborted(status.message)
164164
elif status.code != OK:
165-
raise OperationalError(status.details)
165+
raise OperationalError(status.message)
166166

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

303303
if status.code == ABORTED:
304304
self.connection._transaction = None
305-
raise Aborted(status.details)
305+
raise Aborted(status.message)
306306
elif status.code != OK:
307-
raise OperationalError(status.details)
307+
raise OperationalError(status.message)
308308
break
309309
except Aborted:
310310
self.connection.retry_transaction()

‎tests/unit/spanner_dbapi/test_cursor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ def test_executemany_insert_batch_failed(self):
506506

507507
transaction = mock.Mock(committed=False, rolled_back=False)
508508
transaction.batch_update = mock.Mock(
509-
return_value=(mock.Mock(code=UNKNOWN, details=err_details), [])
509+
return_value=(mock.Mock(code=UNKNOWN, message=err_details), [])
510510
)
511511

512512
with mock.patch(

0 commit comments

Comments
 (0)