You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Raw select queries with binds as select clause fail at runtime with the following error:
thread 'multiconnection::nullable_type_checks' panicked at 'internal error: entered unreachable code: We ensure at the call side that we do not hit this type here. If you ever see this error, something has gone very wrong. Please open an issue at the diesel github repo in this case', diesel/src/mysql/connection/bind.rs:685:50
stack backtrace:
0: rust_begin_unwind
at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panicking.rs:575:5
1: core::panicking::panic_fmt
at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/core/src/panicking.rs:64:14
2: diesel::mysql::connection::bind::<impl core::convert::From<(mysqlclient_sys::enum_field_types,diesel::mysql::connection::bind::Flags)> for diesel::mysql::backend::MysqlType>::from
at /home/weiznich/Documents/rust/diesel/diesel/src/mysql/connection/bind.rs:685:50
3: <T as core::convert::Into<U>>::into
at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/core/src/convert/mod.rs:726:9
4: diesel::mysql::connection::bind::BindData::value
at /home/weiznich/Documents/rust/diesel/diesel/src/mysql/connection/bind.rs:410:23
5: <diesel::mysql::connection::stmt::iterator::MysqlField as diesel::row::Field<diesel::mysql::backend::Mysql>>::value
at /home/weiznich/Documents/rust/diesel/diesel/src/mysql/connection/stmt/iterator.rs:223:72
What are you trying to accomplish?
let mut conn = MysqlConnection::establish("…").unwrap();
#[derive(QueryableByName)]
struct Res {
#[diesel(sql_type = sql_types::Integer)]
bar: i32
}
diesel::sql_query("SELECT ? as bar").bind::<sql_types::Integer, i32>(1).get_result::<Res>(&mut conn);
What is the expected output?
The query runs successful
What is the actual output?
The panic message from above
Are you seeing any additional errors?
Steps to reproduce
let mut conn = MysqlConnection::establish("…").unwrap();
#[derive(QueryableByName)]
struct Res {
#[diesel(sql_type = sql_types::Integer)]
bar: i32
}
diesel::sql_query("SELECT ? as bar").bind::<sql_types::Integer, i32>(1).get_result::<Res>(&mut conn);
Preliminary debugging
This seems to happen because mysql returns MYSQL_TYPE_NULL in such cases and we don't have any type information on our own there. I've tried to just ignore the missing type information but we need the type information for automatically converting to the right numeric type here:
@pxp9 Thanks for that note. I'm well aware of that fact as I'm already done some debugging there + wrote the corresponding panic! call on my own. This issue mostly exists to document that issue for now.
Setup
Versions
Feature Flags
Problem Description
Raw select queries with binds as select clause fail at runtime with the following error:
What are you trying to accomplish?
What is the expected output?
The query runs successful
What is the actual output?
The panic message from above
Are you seeing any additional errors?
Steps to reproduce
Preliminary debugging
This seems to happen because mysql returns
MYSQL_TYPE_NULL
in such cases and we don't have any type information on our own there. I've tried to just ignore the missing type information but we need the type information for automatically converting to the right numeric type here:diesel/diesel/src/mysql/value.rs
Lines 60 to 84 in 02a37df
Checklist
closed if this is not the case)
The text was updated successfully, but these errors were encountered: