Debian Codegraph @

tests/sqlite/any.rs

raw symbols SCIP
1 use sqlx::{Any, Sqlite};
2 use sqlx_test::new;
3
4 #[sqlx_macros::test]
5 async fn it_encodes_bool_with_any() -> anyhow::Result<()> {
6 sqlx::any::install_default_drivers();
7 let mut conn = new::<Any>().await?;
8
9 let res = sqlx::query("INSERT INTO accounts (name, is_active) VALUES (?, ?)")
10 .bind("Harrison Ford")
11 .bind(true)
12 .execute(&mut conn)
13 .await
14 .expect("failed to encode bool");
15 assert_eq!(res.rows_affected(), 1);
16
17 Ok(())
18 }
19
20 #[sqlx_macros::test]
21 async fn issue_3179() -> anyhow::Result<()> {
22 sqlx::any::install_default_drivers();
23
24 let mut conn = new::<Any>().await?;
25
26 // 4294967297 = 2^32
27 let number: i64 = sqlx::query_scalar("SELECT 4294967296")
28 .fetch_one(&mut conn)
29 .await?;
30
31 // Previously, the decoding would use `i32` as an intermediate which would overflow to 0.
32 assert_eq!(number, 4294967296);
33
34 Ok(())
35 }