From 7f172dc05af6d671a10e5c179efa41a90aea6ea0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 30 Jun 2026 12:19:04 +0000 Subject: [PATCH 1/3] Fix executemany fallback rowcount aggregation --- bindings/python/decentdb/__init__.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/bindings/python/decentdb/__init__.py b/bindings/python/decentdb/__init__.py index 3b74ca5a..0ea42e31 100644 --- a/bindings/python/decentdb/__init__.py +++ b/bindings/python/decentdb/__init__.py @@ -2829,10 +2829,19 @@ def bind_row_fast(params): if code != err_ok: _raise_error(code, sql=sql, params=params) + def fetch_affected_rows(params): + affected = ctypes.c_uint64() + code = self._lib.ddb_stmt_affected_rows(self._stmt, ctypes.byref(affected)) + if code != ERR_OK: + _raise_error(code, sql=sql, params=params) + return int(affected.value) + + total_affected = 0 bind_row_fast(normalized_first) code = step_stmt(self._stmt, byref(step_out)) if code != ERR_OK: _raise_error(code, sql=sql, params=normalized_first) + total_affected += fetch_affected_rows(normalized_first) self._bound_param_count = expected_count if "?" in operation: @@ -2855,6 +2864,7 @@ def bind_row_fast(params): code = step_stmt(self._stmt, byref(step_out)) if code != ERR_OK: _raise_error(code, sql=sql, params=params) + total_affected += fetch_affected_rows(params) else: for params in iterator: if isinstance(params, Mapping): @@ -2879,6 +2889,7 @@ def bind_row_fast(params): code = step_stmt(self._stmt, byref(step_out)) if code != ERR_OK: _raise_error(code, sql=sql, params=params) + total_affected += fetch_affected_rows(params) count = ctypes.c_size_t() code = self._lib.ddb_stmt_column_count(self._stmt, ctypes.byref(count)) @@ -2898,11 +2909,7 @@ def bind_row_fast(params): self._store_cached_non_query_metadata(sql) self._query_active = False self._has_buffered_row = False - affected = ctypes.c_uint64() - code = self._lib.ddb_stmt_affected_rows(self._stmt, ctypes.byref(affected)) - if code != ERR_OK: - _raise_error(code, sql=sql, params=None) - self.rowcount = int(affected.value) + self.rowcount = total_affected return self def _decode_current_row(self): From 0ab4247f8a8cf5f3cfe8bfca7db2db22e764ae7e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 30 Jun 2026 12:20:13 +0000 Subject: [PATCH 2/3] Normalize affected-rows check in executemany helper --- bindings/python/decentdb/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindings/python/decentdb/__init__.py b/bindings/python/decentdb/__init__.py index 0ea42e31..f6b37e9c 100644 --- a/bindings/python/decentdb/__init__.py +++ b/bindings/python/decentdb/__init__.py @@ -2832,7 +2832,7 @@ def bind_row_fast(params): def fetch_affected_rows(params): affected = ctypes.c_uint64() code = self._lib.ddb_stmt_affected_rows(self._stmt, ctypes.byref(affected)) - if code != ERR_OK: + if code != err_ok: _raise_error(code, sql=sql, params=params) return int(affected.value) From 0fc9cd5ea13d3387d03ec6af31312a095945b2b4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 30 Jun 2026 17:42:59 +0000 Subject: [PATCH 3/3] fix: cache affected-rows lookup in python executemany fallback --- bindings/python/decentdb/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bindings/python/decentdb/__init__.py b/bindings/python/decentdb/__init__.py index f6b37e9c..34506d84 100644 --- a/bindings/python/decentdb/__init__.py +++ b/bindings/python/decentdb/__init__.py @@ -2806,7 +2806,10 @@ def executemany(self, operation, seq_of_parameters): bind_int64 = self._lib.ddb_stmt_bind_int64 bind_float64 = self._lib.ddb_stmt_bind_float64 bind_text = self._lib.ddb_stmt_bind_text + fetch_stmt_affected_rows = self._lib.ddb_stmt_affected_rows err_ok = ERR_OK + affected = ctypes.c_uint64() + affected_byref = byref(affected) def bind_row_fast(params): for i, param in enumerate(params, start=1): @@ -2830,8 +2833,7 @@ def bind_row_fast(params): _raise_error(code, sql=sql, params=params) def fetch_affected_rows(params): - affected = ctypes.c_uint64() - code = self._lib.ddb_stmt_affected_rows(self._stmt, ctypes.byref(affected)) + code = fetch_stmt_affected_rows(self._stmt, affected_byref) if code != err_ok: _raise_error(code, sql=sql, params=params) return int(affected.value)