sqlx
sqlx copied to clipboard
sqlx sqlite return wrong type.
Bug Description
sqlx sqlite missing return type.
Minimal Reproduction
use sqlx::{Column, Connection, Row};
#[tokio::main]
async fn main() {
let mut x = sqlx::sqlite::SqliteConnection::connect(":memory:")
.await
.unwrap();
sqlx::query(
r#"
CREATE TABLE IF NOT EXISTS test_table (
id INTEGER PRIMARY KEY autoincrement,
numeric_col NUMERIC
);
"#,
)
.execute(&mut x)
.await
.unwrap();
sqlx::query(
r#"
INSERT INTO test_table (
numeric_col) VALUES ( 123.45);
"#,
)
.execute(&mut x)
.await
.unwrap();
let rows = sqlx::query("select * from test_table")
.fetch_all(&mut x)
.await
.unwrap();
for r in rows.iter() {
for col in 0..r.columns().len() {
let c = r.column(col);
println!("{:?}", c);
}
}
}
SqliteColumn { name: id, ordinal: 0, type_info: SqliteTypeInfo(Int64) }
SqliteColumn { name: numeric_col, ordinal: 1, type_info: SqliteTypeInfo(Null) }
Info
- SQLx version: [REQUIRED]
- sqlx = { version = "0.7.3", features = ["sqlite"] }
- SQLx features enabled: [REQUIRED]
- Database server and version: [REQUIRED] (MySQL / Postgres / SQLite <x.y.z>)
- Operating system: [REQUIRED] windows11
-
rustc --version
: [REQUIRED] rustc 1.74.0-nightly (b3aa8e716 2023-09-21)
Just ran into this error. Was trying to use the NUMERIC type, but it sqlx thought it was NULL
I think this docs paragraph could be related to your issue