Bind parameters given to Statement#execute persist beyond the call
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Ruby
- Star
- 845
- Fork
- 220
- Merge trung bình
- 4 ngày 6 giờ
- Pull request đã merge (30 ngày)
- 8
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của sparklemotion/sqlite3-ruby
-
needs-more-info
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 42/100
sparklemotion/sqlite3-ruby#653 · 3 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
sparklemotion/sqlite3-ruby#639 · 4 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
sparklemotion/sqlite3-ruby#628 · 10 bình luận · 1 reaction ·
-
bug help-wanted platform/windows
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
sparklemotion/sqlite3-ruby#618 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
sparklemotion/sqlite3-ruby#573 · 2 bình luận ·
Tất cả issue của sparklemotion/sqlite3-ruby
Issue tương tự
-
🐞 bug pending triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
CircuitVerse/CircuitVerse#8031 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
riscv/riscv-unified-db#2740 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
iOS podspec depends on `React-Codegen`, which resolves to an unrelated pod on CocoaPods trunkĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
GantMan/jail-monkey#380 ·