Bind parameters given to Statement#execute persist beyond the call
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 35/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Ruby
- Estrellas
- 845
- Forks
- 220
- Merge medio
- 4 d 6 h
- PR fusionados (30 d)
- 8
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de sparklemotion/sqlite3-ruby
-
needs-more-info
Dificultad 3/5 1-2 días Aptitud para principiantes 42/100
sparklemotion/sqlite3-ruby#653 · 3 comentarios ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
sparklemotion/sqlite3-ruby#639 · 4 comentarios ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 42/100
sparklemotion/sqlite3-ruby#628 · 10 comentarios · 1 reacción ·
-
bug help-wanted platform/windows
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
sparklemotion/sqlite3-ruby#618 ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
sparklemotion/sqlite3-ruby#573 · 2 comentarios ·
Todos los issues de sparklemotion/sqlite3-ruby
Issues similares
-
🐞 bug pending triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
CircuitVerse/CircuitVerse#8031 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
riscv/riscv-unified-db#2740 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
iOS podspec depends on `React-Codegen`, which resolves to an unrelated pod on CocoaPods trunkAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
GantMan/jail-monkey#380 ·