Skip to content

Fix Python executemany fallback rowcount aggregation - #57

Merged
sphildreth merged 3 commits into
mainfrom
copilot/review-failed-build-run
Jul 1, 2026
Merged

Fix Python executemany fallback rowcount aggregation#57
sphildreth merged 3 commits into
mainfrom
copilot/review-failed-build-run

Conversation

Copilot AI commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

The release workflow failed in the Python binding suite because Cursor.executemany() reported rowcount from only the final row when the generic fallback path was used. This broke newly added coverage for all-NULL and Decimal batch inserts that expect aggregate affected rows.

  • What changed

    • Updated the fallback executemany execution path in bindings/python/decentdb/__init__.py to accumulate affected rows per executed row instead of reading only the final statement’s affected count.
    • Introduced a small local helper to fetch statement affected rows after each step, then summed into total_affected.
    • Set self.rowcount for non-query fallback execution from the accumulated total.
  • Behavioral impact

    • Cursor.rowcount now reflects total rows processed across the entire fallback batch, aligning fallback behavior with fast batch paths and DB-API expectations.
# Before (fallback path): rowcount reflected only the last executed row
cur.executemany("INSERT INTO t VALUES (?, ?, ?)", rows)
assert cur.rowcount == 1  # incorrect for 3-row batch

# After: rowcount reflects total batch effect
cur.executemany("INSERT INTO t VALUES (?, ?, ?)", rows)
assert cur.rowcount == len(rows)  # 3

@sphildreth
sphildreth marked this pull request as ready for review June 30, 2026 12:44
@sphildreth
sphildreth self-requested a review as a code owner June 30, 2026 12:44
Copilot AI review requested due to automatic review settings June 30, 2026 12:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes Python DB-API Cursor.executemany() fallback behavior so Cursor.rowcount reflects the total affected rows across the entire batch (rather than only the last executed row). This aligns fallback execution with the optimized batch paths and typical DB-API expectations, unblocking Python binding suite coverage around batch inserts (e.g., all-NULL and Decimal).

Changes:

  • Accumulate affected rows during fallback executemany() by summing ddb_stmt_affected_rows() after each step.
  • Set self.rowcount for non-query fallback execution to the aggregated total.

Comment on lines +2832 to +2838
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)

Copilot AI requested a review from sphildreth June 30, 2026 17:43
@sphildreth
sphildreth merged commit 6fb5edc into main Jul 1, 2026
3 checks passed
@sphildreth
sphildreth deleted the copilot/review-failed-build-run branch July 1, 2026 02:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants