2023-07-14 23:27:53 +00:00
|
|
|
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?;
|
|
|
|
|
2023-10-19 21:54:01 +00:00
|
|
|
let res = sqlx::query("INSERT INTO accounts (name, is_active) VALUES (?, ?)")
|
2023-07-14 23:27:53 +00:00
|
|
|
.bind("Harrison Ford")
|
|
|
|
.bind(true)
|
|
|
|
.execute(&mut conn)
|
|
|
|
.await
|
|
|
|
.expect("failed to encode bool");
|
|
|
|
assert_eq!(res.rows_affected(), 1);
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
2024-04-13 23:59:13 +00:00
|
|
|
|
|
|
|
#[sqlx_macros::test]
|
|
|
|
async fn issue_3179() -> anyhow::Result<()> {
|
|
|
|
sqlx::any::install_default_drivers();
|
|
|
|
|
|
|
|
let mut conn = new::<Any>().await?;
|
|
|
|
|
|
|
|
// 4294967297 = 2^32
|
|
|
|
let number: i64 = sqlx::query_scalar("SELECT 4294967296")
|
|
|
|
.fetch_one(&mut conn)
|
|
|
|
.await?;
|
|
|
|
|
|
|
|
// Previously, the decoding would use `i32` as an intermediate which would overflow to 0.
|
|
|
|
assert_eq!(number, 4294967296);
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|