Bind parameters given to Statement#execute persist beyond the call
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 35/100
調査の方向性
Start from Statement#execute and bind_params, and run the two Ruby snippets in the issue to see the leftover state. Done means parameters passed to execute apply only to that call, while values set with bind_params still persist. The issue leaves the allocation trade-off open, so check with maintainers before choosing an approach.
索引モデルが issue の本文から書いたものです。
説明
Discussed in https://github.com/sparklemotion/sqlite3-ruby/discussions/740
Originally posted by jeremyevans September 7, 2026
I found this behavior surprising. I'm not sure whether it is bug, since there is a simple implementation reason for it, but I don't know whether the behavior is expected or desired. Here's a simple example:
db = SQLite3::Database.new ":memory:"
stmt = db.prepare "SELECT :a + :b"
stmt.execute(a: 1, b: 2).to_a # => [[3]]
stmt.execute(a: 2).to_a # => [[4]]
stmt.execute(b: 3).to_a # => [[5]]
stmt.execute.to_a # => [[5]]
As you can see in the example, if you don't provide a bind parameter to execute, it uses the last bound value. I believe it works this way because execute calls bind_params if given any parameters, but it does not reset the preexisting bind parameter state after the statement executes.
You cannot reset the entire bind parameter state in execute, because this code is expected to work:
db = SQLite3::Database.new ":memory:"
stmt = db.prepare "SELECT :a + :b"
stmt.bind_params(a: 1)
stmt.execute(b: 2).to_a # => [[3]]
stmt.execute(b: 3).to_a # => [[4]]
My personal expectation would be that parameters given to execute only apply to that specific execution and not any subsequent executions. However, I realize that requires an allocation in the case where there are already bound parameters on the statement.
Note that this is only an issue when you have multiple execute calls on the statement, and a bind parameter set by one of the earlier execute calls is not set on a later one.
- 主要言語
- Ruby
- スター
- 845
- フォーク
- 220
- 平均マージ
- 4日 6時間
- マージ済み PR(30日)
- 8
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
sparklemotion/sqlite3-ruby のほかの issue
-
needs-more-info
難易度 3/5 1〜2日 初心者へのやさしさ 42/100
sparklemotion/sqlite3-ruby#653 · コメント 3 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
sparklemotion/sqlite3-ruby#639 · コメント 4 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
sparklemotion/sqlite3-ruby#628 · コメント 10 件 · リアクション 1 件 ·
-
bug help-wanted platform/windows
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
sparklemotion/sqlite3-ruby#618 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
sparklemotion/sqlite3-ruby#573 · コメント 2 件 ·
sparklemotion/sqlite3-ruby の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
TheOdinProject/curriculum#31465 ·
メンテナーはふだん 1 日以内に返信
-
agent:triaged bug bughunt pm:bundler priority:p1
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
SocketDev/socket-patch#1573 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Generated server webpack config keeps Rspack's manifest and CSS extraction plugins対応中かも @justin808 が今日担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
shakacode/react_on_rails#5184 ·
メンテナーはふだん 1 日以内に返信
-
bug chat verified
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 6 日以内に返信
-
🐞 bug pending triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
CircuitVerse/CircuitVerse#8031 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信