mirror of
https://github.com/launchbadge/sqlx
synced 2024-11-10 06:24:16 +00:00
fix(sqlite): encode bool as integer (#2620)
This commit is contained in:
parent
1d1095e94f
commit
3662bdab84
3 changed files with 25 additions and 0 deletions
|
@ -211,6 +211,11 @@ name = "sqlite"
|
|||
path = "tests/sqlite/sqlite.rs"
|
||||
required-features = ["sqlite"]
|
||||
|
||||
[[test]]
|
||||
name = "sqlite-any"
|
||||
path = "tests/sqlite/any.rs"
|
||||
required-features = ["sqlite"]
|
||||
|
||||
[[test]]
|
||||
name = "sqlite-types"
|
||||
path = "tests/sqlite/types.rs"
|
||||
|
|
|
@ -205,6 +205,7 @@ fn map_arguments(args: AnyArguments<'_>) -> SqliteArguments<'_> {
|
|||
.into_iter()
|
||||
.map(|val| match val {
|
||||
AnyValueKind::Null => SqliteArgumentValue::Null,
|
||||
AnyValueKind::Bool(b) => SqliteArgumentValue::Int(b as i32),
|
||||
AnyValueKind::SmallInt(i) => SqliteArgumentValue::Int(i as i32),
|
||||
AnyValueKind::Integer(i) => SqliteArgumentValue::Int(i),
|
||||
AnyValueKind::BigInt(i) => SqliteArgumentValue::Int64(i),
|
||||
|
|
19
tests/sqlite/any.rs
Normal file
19
tests/sqlite/any.rs
Normal file
|
@ -0,0 +1,19 @@
|
|||
use sqlx::{Any, Sqlite};
|
||||
use sqlx_test::new;
|
||||
|
||||
#[sqlx_macros::test]
|
||||
async fn it_encodes_bool_with_any() -> anyhow::Result<()> {
|
||||
sqlx::any::install_default_drivers();
|
||||
let mut conn = new::<Any>().await?;
|
||||
|
||||
let res = sqlx::query("INSERT INTO accounts VALUES (?, ?, ?)")
|
||||
.bind(87)
|
||||
.bind("Harrison Ford")
|
||||
.bind(true)
|
||||
.execute(&mut conn)
|
||||
.await
|
||||
.expect("failed to encode bool");
|
||||
assert_eq!(res.rows_affected(), 1);
|
||||
|
||||
Ok(())
|
||||
}
|
Loading…
Reference in a new issue