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
If have a table with one column having the JSON type (internally defined as LONGTEXT by MariaDB). I used to be able to decode this with query_as into a String. Roughly since version 0.8 this panics:
error occurred while decoding column 1: mismatched types; Rust type alloc::string::String (as SQL type VARCHAR) is not compatible with SQL type BLOB
Minimal Reproduction
CREATETABLEIF NOT EXISTS my_table (
name VARCHAR(64) PRIMARY KEY,
json_definition JSON
CHECK (JSON_VALID(json_definition))
);
INSERT INTO my_table (name, json_definition) VALUES ("foo", "{\"bar\":true}");
/*let POOL = MySqlPoolOptions::new() .max_connections(100) .acquire_timeout(Duration::from_secs(30)) .idle_timeout(Duration::from_secs(10)) .connect_with({ let options = MySqlConnectOptions::new() .host(CONFIG.get().unwrap().db_host.as_str()) .username("api") .password(CONFIG.get().unwrap().db_password.as_str()) .charset("utf8mb4") .database("warehouse") .log_statements(LevelFilter::Debug) .log_slow_statements( LevelFilter::Warn, std::time::Duration::from_millis(1000), ); options }) .await .unwrap();*/let row:Option<(String,String)> =
sqlx::query_as("SELECT name, json_definition FROM my_table WHERE name=?").bind("foo").fetch_optional(POOL).awaitunwrap();
Info
SQLx version: 0.8.2 (it works fine on sqlx 0.7.4)
SQLx features enabled: [ "runtime-tokio-rustls" , "mysql", "chrono" ]
Bug Description
If have a table with one column having the
JSON
type (internally defined asLONGTEXT
by MariaDB). I used to be able to decode this withquery_as
into aString
. Roughly since version 0.8 this panics:Minimal Reproduction
Info
0.8.2
(it works fine onsqlx 0.7.4
)[ "runtime-tokio-rustls" , "mysql", "chrono" ]
rustc --version
:rustc 1.85.0-nightly (4d669fb34 2024-12-08)
The text was updated successfully, but these errors were encountered: