-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Binding a null value should never fail #3558
Comments
Thanks for opening this issue. It seems like you triggered an internal error that is not supposed to be triggered. That written: It does not change the result, your query will error anyway because it does not contain a bind parameter. Fixed query: (note the removed let child = sql_query(
r#"WITH RECURSIVE CTE AS (
SELECT id, slug AS path
FROM pages
WHERE parent_id IS NULL
UNION ALL
SELECT p.id, path || '/' || slug
FROM pages p
JOIN CTE ON p.parent_id = CTE.id
)
SELECT *
FROM CTE
WHERE path = ?
"#,
); I'm leaving this issue open for now, because the error message should be improved in diesel. |
I've opened #3560 to fix the panic. |
This commit fixes an issue where out of bound text/binary binds on `sql_query` using the sqlite backend causes a panic in an internal drop impl. It was caused that we pushed to the list of released binds before we actually checked whether that bind was possible or not. This caused us trying to bind to the same invalid bind again in the drop impl, while being on the normal error path. It's fixed by just moving the relevant push after the actual bind. In addition a regression test for this problem is added.
This commit fixes an issue where out of bound text/binary binds on `sql_query` using the sqlite backend causes a panic in an internal drop impl. It was caused that we pushed to the list of released binds before we actually checked whether that bind was possible or not. This caused us trying to bind to the same invalid bind again in the drop impl, while being on the normal error path. It's fixed by just moving the relevant push after the actual bind. In addition a regression test for this problem is added.
Setup
Versions
rustc 1.68.0
2.0.0
Sqlite
NixOS
Feature Flags
["sqlite", "r2d2"]
Problem Description
What are you trying to accomplish?
Perform a recursive CTE query to load an item from a path spec, using
sql_query
and a struct derivingQueryableByName
What is the expected output?
The columns desired are selected
What is the actual output?
thread 'rocket-worker-thread' panicked at 'Binding a null value should never fail. If you ever see this error message please open an issue at diesels issue tracker containing code how to trigger this message.: DatabaseError(Unknown, "column index out of range")', /home/leonid/.cargo/registry/src/index.crates.io-6f17d22bba15001f/diesel-2.0.3/src/sqlite/connection/stmt.rs:344:22
Are you seeing any additional errors?
N/A
Steps to reproduce
main.rs
models.rs
schema.rs
up.sql for pages
Database contains one page row in table pages,
1 | NULL | foo | foo | <p>bar</p>
Checklist
closed if this is not the case)
I use dotenvy to set up the db, but it is not required.
The text was updated successfully, but these errors were encountered: