Content-Length: 1980 | pFad | http://www.github.com/googleapis/python-bigquery/pull/660.patch
ithub.com
From 5eda9c69c6a5cc299561b46c263fe78375eaf141 Mon Sep 17 00:00:00 2001
From: Jim Fulton
Date: Tue, 11 May 2021 09:32:33 -0600
Subject: [PATCH] fix: executemany rowcount only reflected the last execution
---
google/cloud/bigquery/dbapi/cursor.py | 4 ++++
tests/unit/test_dbapi_cursor.py | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/google/cloud/bigquery/dbapi/cursor.py b/google/cloud/bigquery/dbapi/cursor.py
index f74781df9..c8fc49378 100644
--- a/google/cloud/bigquery/dbapi/cursor.py
+++ b/google/cloud/bigquery/dbapi/cursor.py
@@ -218,6 +218,7 @@ def executemany(self, operation, seq_of_parameters):
Sequence of many sets of parameter values.
"""
if seq_of_parameters:
+ rowcount = 0
# There's no reason to format the line more than once, as
# the operation only barely depends on the parameters. So
# we just use the first set of parameters. If there are
@@ -230,6 +231,9 @@ def executemany(self, operation, seq_of_parameters):
self._execute(
formatted_operation, parameters, None, None, parameter_types
)
+ rowcount += self.rowcount
+
+ self.rowcount = rowcount
def _try_fetch(self, size=None):
"""Try to start fetching data, if not yet started.
diff --git a/tests/unit/test_dbapi_cursor.py b/tests/unit/test_dbapi_cursor.py
index 5afe269ef..55e453254 100644
--- a/tests/unit/test_dbapi_cursor.py
+++ b/tests/unit/test_dbapi_cursor.py
@@ -612,7 +612,7 @@ def test_executemany_w_dml(self):
(("test",), ("anothertest",)),
)
self.assertIsNone(cursor.description)
- self.assertEqual(cursor.rowcount, 12)
+ self.assertEqual(cursor.rowcount, 24) # 24 because 2 * 12 because cumulatve.
def test_executemany_empty(self):
from google.cloud.bigquery.dbapi import connect
--- a PPN by Garber Painting Akron. With Image Size Reduction included!Fetched URL: http://www.github.com/googleapis/python-bigquery/pull/660.patch
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy