mirror of
https://github.com/launchbadge/sqlx.git
synced 2026-04-05 09:53:45 +00:00
breaking: add SqlStr (#3723)
* refactor: introduce `SqlSafeStr` API * rebase main * Add SqlStr + remove Statement lifetime * Update the definition of Executor and AnyConnectionBackend + update Postgres driver * Update MySql driver * Update Sqlite driver * remove debug clone count * Reduce the amount of SqlStr clones * improve QueryBuilder error message * cargo fmt * fix clippy warnings * fix doc test * Avoid panic in `QueryBuilder::reset` * Use `QueryBuilder` when removing all test db's * Add comment to `SqlStr` Co-authored-by: Austin Bonander <austin.bonander@gmail.com> * Update sqlx-core/src/query_builder.rs Co-authored-by: Austin Bonander <austin.bonander@gmail.com> * Add `Clone` as supertrait to `Statement` * Move `Connection`, `AnyConnectionBackend` and `TransactionManager` to `SqlStr` * Replace `sql_cloned` with `sql` in `Statement` * Update `Executor` trait * Update unit tests + QueryBuilder changes * Remove code in comments * Update comment in `QueryBuilder` * Fix clippy warnings * Update `Migrate` comment * Small changes * Move `Migration` to `SqlStr` --------- Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
This commit is contained in:
@@ -108,13 +108,14 @@ macro_rules! test_unprepared_type {
|
||||
#[sqlx_macros::test]
|
||||
async fn [< test_unprepared_type_ $name >] () -> anyhow::Result<()> {
|
||||
use sqlx::prelude::*;
|
||||
use sqlx_core::sql_str::AssertSqlSafe;
|
||||
use futures_util::TryStreamExt;
|
||||
|
||||
let mut conn = sqlx_test::new::<$db>().await?;
|
||||
|
||||
$(
|
||||
let query = format!("SELECT {}", $text);
|
||||
let mut s = conn.fetch(&*query);
|
||||
let mut s = conn.fetch(AssertSqlSafe(query));
|
||||
let row = s.try_next().await?.unwrap();
|
||||
let rec = row.try_get::<$ty, _>(0)?;
|
||||
|
||||
@@ -137,13 +138,14 @@ macro_rules! __test_prepared_decode_type {
|
||||
#[sqlx_macros::test]
|
||||
async fn [< test_prepared_decode_type_ $name >] () -> anyhow::Result<()> {
|
||||
use sqlx::Row;
|
||||
use sqlx_core::sql_str::AssertSqlSafe;
|
||||
|
||||
let mut conn = sqlx_test::new::<$db>().await?;
|
||||
|
||||
$(
|
||||
let query = format!("SELECT {}", $text);
|
||||
|
||||
let row = sqlx::query(&query)
|
||||
let row = sqlx::query(AssertSqlSafe(query))
|
||||
.fetch_one(&mut conn)
|
||||
.await?;
|
||||
|
||||
@@ -166,6 +168,7 @@ macro_rules! __test_prepared_type {
|
||||
#[sqlx_macros::test]
|
||||
async fn [< test_prepared_type_ $name >] () -> anyhow::Result<()> {
|
||||
use sqlx::Row;
|
||||
use sqlx_core::sql_str::AssertSqlSafe;
|
||||
|
||||
let mut conn = sqlx_test::new::<$db>().await?;
|
||||
|
||||
@@ -173,7 +176,7 @@ macro_rules! __test_prepared_type {
|
||||
let query = format!($sql, $text);
|
||||
println!("{query}");
|
||||
|
||||
let row = sqlx::query(&query)
|
||||
let row = sqlx::query(AssertSqlSafe(query))
|
||||
.bind($value)
|
||||
.bind($value)
|
||||
.fetch_one(&mut conn)
|
||||
|
||||
Reference in New Issue
Block a user