Repository navigation
doc: bound parameters persist across executions - #760
Merged
Merged
Conversation
Parameters bound by `Statement#execute` stay bound, so a later `#execute` that omits one reuses the earlier value. This was undocumented. Document this on `Statement#execute`, `#execute!`, `#bind_param`, `#bind_params`, `#reset!` and `ResultSet#reset`, and in the FAQ. Point to `#clear_bindings!`, and fix its description, which was copied from `#reset!`. [Fix #751]
flavorjones
force-pushed
the
card-793-document-sticky-bind-params
branch
from
October 24, 2026 16:12
5b4198c to
0122a01
Compare
flavorjones
enabled auto-merge (squash)
October 24, 2026 16:20
flavorjones
disabled auto-merge
October 24, 2026 16:29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Fixes #751.
As reported in #751, parameters passed to
Statement#executestay bound after the call, so a later#executethat omits a parameter reuses the earlier value:#executebinds through#bind_params(statement.rb), and SQLite keeps bindings until they are cleared. Changing this would break code that relies on it (see #757, now closed), so I am documenting it instead.Details
The docs for
Statement#execute,#execute!,#bind_param,#bind_params,#reset!andResultSet#resetnow say that bound values persist across executions.#executeand the FAQ show the example above, and point toStatement#clear_bindings!to set every parameter back to NULL. The FAQ also notes that theDatabase#executefamily prepares a new statement for each call, so it is unaffected.The
#clear_bindings!description was a copy of the one for#reset!; it now says what the method does.