From 3f5c37d4c7f9d82001b7661f8d2738cddec800c9 Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Tue, 28 Sep 2021 11:06:50 +0300 Subject: [PATCH 1/3] feat(db_api): raise exception with message for executemany() --- google/cloud/spanner_dbapi/cursor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/google/cloud/spanner_dbapi/cursor.py b/google/cloud/spanner_dbapi/cursor.py index cf15b99a55..7f538c8d91 100644 --- a/google/cloud/spanner_dbapi/cursor.py +++ b/google/cloud/spanner_dbapi/cursor.py @@ -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() From 962cc47e46cb205569078011ec79e46be1c4cffc Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Tue, 28 Sep 2021 11:11:28 +0300 Subject: [PATCH 2/3] one more place --- google/cloud/spanner_dbapi/cursor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/google/cloud/spanner_dbapi/cursor.py b/google/cloud/spanner_dbapi/cursor.py index 7f538c8d91..b355d24dd6 100644 --- a/google/cloud/spanner_dbapi/cursor.py +++ b/google/cloud/spanner_dbapi/cursor.py @@ -164,9 +164,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. From 9529b08efaf11e2368a56651f63c59f7d72a273d Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Tue, 28 Sep 2021 11:36:56 +0300 Subject: [PATCH 3/3] fix unit test --- tests/unit/spanner_dbapi/test_cursor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/spanner_dbapi/test_cursor.py b/tests/unit/spanner_dbapi/test_cursor.py index 038f419351..f1f65437d2 100644 --- a/tests/unit/spanner_dbapi/test_cursor.py +++ b/tests/unit/spanner_dbapi/test_cursor.py @@ -500,7 +500,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(