Skip to content

fix: Refuse unbindable data frame columns before binding in dbBind(), and tidy up after the stack review - #976

Draft
krlmlr wants to merge 8 commits into
claude/rb-arrow-param-checksfrom
claude/rb-stack-review-write
Draft

krlmlr wants to merge 8 commits into
claude/rb-arrow-param-checksfrom
claude/rb-stack-review-write

Conversation

@krlmlr

@krlmlr krlmlr commented Dec 1, 2026

Copy link
Copy Markdown
Member

A follow-up of the review of the whole stack at its top, on the write side. The plan is in #880.

What changes for users: dbBind() now refuses a vector it can't bind (a complex vector, or a list with an element that is neither raw nor NULL) before it binds anything, and the result keeps its previous binding, as it already did for the wrong number of parameters and as an Arrow column of a type that can't be bound (such as decimal128) does. Before, the data frame path failed in the first row that reached the bad element: it ran the parameter sets before that element and left the result unbound, so the same kind of type error left a different state than on the Arrow path, against the NEWS promise that input refused before binding keeps the previous binding. The error keeps its class (RSQLite_error_error) and message. Tests that relied on a list element failing in a later row now exceed SQLite's length limit instead, which still fails in that row.

Also, with no change of behavior: the NEWS sentence about the call of an error in dbExecute() compares with what RSQLite 3.54.1 showed (no call) rather than with an earlier state of this unreleased stack; ?"RSQLite-conditions" says that an error of dbGetQuery() in a row after the first names dbFetch(); the comments that said Arrow binds "as dbBind() binds a data frame" now state the two deliberate differences (a null struct row binds NULL, and uint32, int64 and uint64 bind as INTEGER where the converted data frame binds REAL); connection_connect() returns the SEXP of its external pointer, as result_create() does, instead of relying on NRVO to keep its tag and finalizer; and the unused SqliteError::code() is gone.

Tested: the new tests in test-dbBind.R and test-arrow-bind.R fail on the base (four tests) and pass with the fix. The full suite with NOT_CRAN=true gives FAIL 0, WARN 7, SKIP 64, PASS 13470.

Based on #971, the top of stack #928. Not ported from an old PR.

Coordinating session: https://claude.ai/code/session_01Hr1rd7QnTD4acgzTUihnF4



Generated by Claude Code

A complex vector, or a list with an element that is neither raw nor NULL,
now fails before the result drops its previous bind,
as an Arrow column of a type that can't be bound does.
Before, it failed in the first row it reached:
the result was left unbound after running the parameter sets before it.
The error keeps its class and message.

The tests that let a later parameter set fail to bind
now exceed SQLite's length limit instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd7QnTD4acgzTUihnF4
…they are

An error of `dbGetQuery()` names `dbFetch()` for a row after the first,
and NEWS compares the call of an error in `dbExecute()` with RSQLite 3.54.1,
which gave no call.
An Arrow stream binds a null struct row as NULL,
and uint32, int64 and uint64 values as integers,
where the data frame that nanoarrow converts it to keeps the values
and holds doubles that bind as reals.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd7QnTD4acgzTUihnF4
…qliteError::code()`

The external pointer of `connection_connect()` kept its tag and finalizer
only through the named return value optimization,
as cpp11's move constructor makes a new pointer without them.
It now returns the SEXP itself, as `result_create()` does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd7QnTD4acgzTUihnF4
@krlmlr
krlmlr added this pull request to stack #928 December 1, 2026 11:37
…d list element

`dbBind()` refuses `raw(0)` and `complex(0)` and keeps the previous bind,
and `dbGetQuery()` raises the error of a list element in a later row from `dbBind()`,
with no `rows` and before any row runs.
The tests clear their result on exit if it is still valid.
NEWS cites the pull request for the whole change
and says that the error's call is `dbBind()`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd7QnTD4acgzTUihnF4

This branch has not been deployed

No deployments
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.

2 participants