-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
sqlx think medium text as binary? #3390
Comments
any sql mysql version 8 have this issue too. |
@yuyang-ok $ docker run --rm -p 10000:3306 -e MYSQL_ROOT_PASSWORD=root_pass mysql:9.0.1 let pool = sqlx::MySqlPool::connect("mysql://root:root_pass@localhost:10000")
.await
.unwrap();
sqlx::query("CREATE DATABASE IF NOT EXISTS issue_3390_db")
.execute(&pool)
.await
.unwrap();
let pool = sqlx::MySqlPool::connect("mysql://root:root_pass@localhost:10000/issue_3390_db")
.await
.unwrap();
sqlx::query("DROP TABLE IF EXISTS issue_3390_table")
.execute(&pool)
.await
.unwrap();
sqlx::query(
"CREATE TABLE issue_3390_table (id INT AUTO_INCREMENT PRIMARY KEY, name MEDIUMTEXT)",
)
.execute(&pool)
.await
.unwrap();
sqlx::query("INSERT INTO issue_3390_table (name) VALUES(?)")
.bind("name")
.execute(&pool)
.await
.unwrap();
#[derive(Debug, PartialEq, Eq, sqlx::FromRow)]
#[allow(unused)]
struct Row {
id: i32,
name: String,
}
let row: Row = sqlx::query_as("SELECT id, name FROM issue_3390_table")
.fetch_one(&pool)
.await
.unwrap();
assert_eq!(
row,
Row {
id: 1,
name: "name".into()
}
); |
@alu I think they're talking about the output of a This might be the same issue as #3387 |
I used It seems to work as expected if BINARY is also accepted by compatible
|
@DrewMcArthur thanks. |
The same thing happeing with SQLite and SQLX create table test_table(
id integer primary key autoicrement,
body TEXT not null
) When i use let channels_raw: Vec<SqliteRow> =
sqlx::query("select body from test_table")
.fetch_all(&pool)
.await
.unwrap();
println!("type from column: {:?}", channels_raw[0].columns()[0]);
println!("type from value: {:?}", channels_raw[0].try_get_raw(0).unwrap().type_info()); this produces output
@yuyang-ok I can't explain this discrepancy. |
@eirnym I am not familiar with this library too. I don't know how to fix this |
I wanted to emphasise that this issue is not only for MySQL, but it is probably for all SQL engines supported. |
@eirnym that's a different issue entirely and is likely correct behavior. Please read about how data types and storage work in SQLite: https://www.sqlite.org/datatype3.html |
Bug Description
thread 'mysql::tests::test_rename' panicked at dbnexus-db/src/mysql.rs:1396:14: called `Result::unwrap()` on an `Err` value: 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
Info
mysql 9.0.1
rustc --version
: [REQUIRED]The text was updated successfully, but these errors were encountered: