Revert "Upgrade SQLx to v0.7"

This reverts commit 832fabf8ff296896231c0d00bc42ecde779c6d5f.
This commit is contained in:
Billy Chan 2023-07-07 16:31:15 +08:00
parent 832fabf8ff
commit acca634e03
No known key found for this signature in database
GPG Key ID: A2D690CAC7DF3CC7
8 changed files with 60 additions and 60 deletions

View File

@ -34,12 +34,12 @@ tracing = { version = "0.1", default-features = false, features = ["attributes",
rust_decimal = { version = "1", default-features = false, optional = true } rust_decimal = { version = "1", default-features = false, optional = true }
bigdecimal = { version = "0.3", default-features = false, optional = true } bigdecimal = { version = "0.3", default-features = false, optional = true }
sea-orm-macros = { version = "0.12.0-rc.3", path = "sea-orm-macros", default-features = false, features = ["strum"] } sea-orm-macros = { version = "0.12.0-rc.3", path = "sea-orm-macros", default-features = false, features = ["strum"] }
sea-query = { version = "0.29.0", git = "https://github.com/seaql/sea-query", branch = "sqlx-v0.7", features = ["thread-safe"] } sea-query = { version = "0.29.0-rc.2", features = ["thread-safe"] }
sea-query-binder = { version = "0.4.0", git = "https://github.com/seaql/sea-query", branch = "sqlx-v0.7", default-features = false, optional = true } sea-query-binder = { version = "0.4.0-rc.2", default-features = false, optional = true }
strum = { version = "0.24", default-features = false } strum = { version = "0.24", default-features = false }
serde = { version = "1.0", default-features = false } serde = { version = "1.0", default-features = false }
serde_json = { version = "1.0", default-features = false, optional = true } serde_json = { version = "1.0", default-features = false, optional = true }
sqlx = { version = "0.7", default-features = false, optional = true } sqlx = { version = "0.6", default-features = false, optional = true }
uuid = { version = "1", default-features = false, optional = true } uuid = { version = "1", default-features = false, optional = true }
ouroboros = { version = "0.15", default-features = false } ouroboros = { version = "0.15", default-features = false }
url = { version = "2.2", default-features = false } url = { version = "2.2", default-features = false }
@ -78,7 +78,7 @@ macros = ["sea-orm-macros/derive", "sea-query/derive"]
mock = [] mock = []
with-json = ["serde_json", "sea-query/with-json", "chrono?/serde", "time?/serde", "uuid?/serde", "sea-query-binder?/with-json", "sqlx?/json"] with-json = ["serde_json", "sea-query/with-json", "chrono?/serde", "time?/serde", "uuid?/serde", "sea-query-binder?/with-json", "sqlx?/json"]
with-chrono = ["chrono", "sea-query/with-chrono", "sea-query-binder?/with-chrono", "sqlx?/chrono"] with-chrono = ["chrono", "sea-query/with-chrono", "sea-query-binder?/with-chrono", "sqlx?/chrono"]
with-rust_decimal = ["rust_decimal", "sea-query/with-rust_decimal", "sea-query-binder?/with-rust_decimal", "sqlx?/rust_decimal"] with-rust_decimal = ["rust_decimal", "sea-query/with-rust_decimal", "sea-query-binder?/with-rust_decimal", "sqlx?/decimal"]
with-bigdecimal = ["bigdecimal", "sea-query/with-bigdecimal", "sea-query-binder?/with-bigdecimal", "sqlx?/bigdecimal"] with-bigdecimal = ["bigdecimal", "sea-query/with-bigdecimal", "sea-query-binder?/with-bigdecimal", "sqlx?/bigdecimal"]
with-uuid = ["uuid", "sea-query/with-uuid", "sea-query-binder?/with-uuid", "sqlx?/uuid"] with-uuid = ["uuid", "sea-query/with-uuid", "sea-query-binder?/with-uuid", "sqlx?/uuid"]
with-time = ["time", "sea-query/with-time", "sea-query-binder?/with-time", "sqlx?/time"] with-time = ["time", "sea-query/with-time", "sea-query-binder?/with-time", "sqlx?/time"]
@ -102,12 +102,12 @@ runtime-async-std-rustls = [
] ]
runtime-actix = [] runtime-actix = []
runtime-actix-native-tls = [ runtime-actix-native-tls = [
"sqlx?/runtime-tokio-native-tls", "sqlx?/runtime-actix-native-tls",
"sea-query-binder?/runtime-actix-native-tls", "sea-query-binder?/runtime-actix-native-tls",
"runtime-actix", "runtime-actix",
] ]
runtime-actix-rustls = [ runtime-actix-rustls = [
"sqlx?/runtime-tokio-rustls", "sqlx?/runtime-actix-rustls",
"sea-query-binder?/runtime-actix-rustls", "sea-query-binder?/runtime-actix-rustls",
"runtime-actix", "runtime-actix",
] ]

View File

@ -39,7 +39,7 @@ dotenvy = { version = "0.15", default-features = false, optional = true }
async-std = { version = "1.9", default-features = false, features = ["attributes", "tokio1"], optional = true } async-std = { version = "1.9", default-features = false, features = ["attributes", "tokio1"], optional = true }
sea-orm-codegen = { version = "=0.12.0-rc.3", path = "../sea-orm-codegen", default-features = false, optional = true } sea-orm-codegen = { version = "=0.12.0-rc.3", path = "../sea-orm-codegen", default-features = false, optional = true }
sea-schema = { version = "0.12.0-rc.2" } sea-schema = { version = "0.12.0-rc.2" }
sqlx = { version = "0.7", default-features = false, features = ["mysql", "postgres"], optional = true } sqlx = { version = "0.6", default-features = false, features = ["mysql", "postgres"], optional = true }
tracing-subscriber = { version = "0.3.17", default-features = false, features = ["env-filter", "fmt"] } tracing-subscriber = { version = "0.3.17", default-features = false, features = ["env-filter", "fmt"] }
tracing = { version = "0.1", default-features = false } tracing = { version = "0.1", default-features = false }
url = { version = "2.2", default-features = false } url = { version = "2.2", default-features = false }

View File

@ -17,7 +17,7 @@ name = "sea_orm_codegen"
path = "src/lib.rs" path = "src/lib.rs"
[dependencies] [dependencies]
sea-query = { version = "0.29.0", git = "https://github.com/seaql/sea-query", branch = "sqlx-v0.7", default-features = false, features = ["thread-safe"] } sea-query = { version = "0.29.0-rc.2", default-features = false, features = ["thread-safe"] }
syn = { version = "2", default-features = false, features = ["parsing", "proc-macro", "derive", "printing"] } syn = { version = "2", default-features = false, features = ["parsing", "proc-macro", "derive", "printing"] }
quote = { version = "1", default-features = false } quote = { version = "1", default-features = false }
heck = { version = "0.4", default-features = false } heck = { version = "0.4", default-features = false }

View File

@ -310,26 +310,26 @@ impl ConnectionTrait for DatabaseTransaction {
match &mut *self.conn.lock().await { match &mut *self.conn.lock().await {
#[cfg(feature = "sqlx-mysql")] #[cfg(feature = "sqlx-mysql")]
InnerConnection::MySql(ref mut conn) => { InnerConnection::MySql(conn) => {
let query = crate::driver::sqlx_mysql::sqlx_query(&stmt); let query = crate::driver::sqlx_mysql::sqlx_query(&stmt);
crate::metric::metric!(self.metric_callback, &stmt, { crate::metric::metric!(self.metric_callback, &stmt, {
query.execute(&mut **conn).await.map(Into::into) query.execute(conn).await.map(Into::into)
}) })
.map_err(sqlx_error_to_exec_err) .map_err(sqlx_error_to_exec_err)
} }
#[cfg(feature = "sqlx-postgres")] #[cfg(feature = "sqlx-postgres")]
InnerConnection::Postgres(ref mut conn) => { InnerConnection::Postgres(conn) => {
let query = crate::driver::sqlx_postgres::sqlx_query(&stmt); let query = crate::driver::sqlx_postgres::sqlx_query(&stmt);
crate::metric::metric!(self.metric_callback, &stmt, { crate::metric::metric!(self.metric_callback, &stmt, {
query.execute(&mut **conn).await.map(Into::into) query.execute(conn).await.map(Into::into)
}) })
.map_err(sqlx_error_to_exec_err) .map_err(sqlx_error_to_exec_err)
} }
#[cfg(feature = "sqlx-sqlite")] #[cfg(feature = "sqlx-sqlite")]
InnerConnection::Sqlite(ref mut conn) => { InnerConnection::Sqlite(conn) => {
let query = crate::driver::sqlx_sqlite::sqlx_query(&stmt); let query = crate::driver::sqlx_sqlite::sqlx_query(&stmt);
crate::metric::metric!(self.metric_callback, &stmt, { crate::metric::metric!(self.metric_callback, &stmt, {
query.execute(&mut **conn).await.map(Into::into) query.execute(conn).await.map(Into::into)
}) })
.map_err(sqlx_error_to_exec_err) .map_err(sqlx_error_to_exec_err)
} }
@ -347,17 +347,17 @@ impl ConnectionTrait for DatabaseTransaction {
match &mut *self.conn.lock().await { match &mut *self.conn.lock().await {
#[cfg(feature = "sqlx-mysql")] #[cfg(feature = "sqlx-mysql")]
InnerConnection::MySql(ref mut conn) => sqlx::Executor::execute(&mut **conn, sql) InnerConnection::MySql(conn) => sqlx::Executor::execute(conn, sql)
.await .await
.map(Into::into) .map(Into::into)
.map_err(sqlx_error_to_exec_err), .map_err(sqlx_error_to_exec_err),
#[cfg(feature = "sqlx-postgres")] #[cfg(feature = "sqlx-postgres")]
InnerConnection::Postgres(ref mut conn) => sqlx::Executor::execute(&mut **conn, sql) InnerConnection::Postgres(conn) => sqlx::Executor::execute(conn, sql)
.await .await
.map(Into::into) .map(Into::into)
.map_err(sqlx_error_to_exec_err), .map_err(sqlx_error_to_exec_err),
#[cfg(feature = "sqlx-sqlite")] #[cfg(feature = "sqlx-sqlite")]
InnerConnection::Sqlite(ref mut conn) => sqlx::Executor::execute(&mut **conn, sql) InnerConnection::Sqlite(conn) => sqlx::Executor::execute(conn, sql)
.await .await
.map(Into::into) .map(Into::into)
.map_err(sqlx_error_to_exec_err), .map_err(sqlx_error_to_exec_err),
@ -379,29 +379,29 @@ impl ConnectionTrait for DatabaseTransaction {
match &mut *self.conn.lock().await { match &mut *self.conn.lock().await {
#[cfg(feature = "sqlx-mysql")] #[cfg(feature = "sqlx-mysql")]
InnerConnection::MySql(ref mut conn) => { InnerConnection::MySql(conn) => {
let query = crate::driver::sqlx_mysql::sqlx_query(&stmt); let query = crate::driver::sqlx_mysql::sqlx_query(&stmt);
crate::metric::metric!(self.metric_callback, &stmt, { crate::metric::metric!(self.metric_callback, &stmt, {
Self::map_err_ignore_not_found( Self::map_err_ignore_not_found(
query.fetch_one(&mut **conn).await.map(|row| Some(row.into())), query.fetch_one(conn).await.map(|row| Some(row.into())),
) )
}) })
} }
#[cfg(feature = "sqlx-postgres")] #[cfg(feature = "sqlx-postgres")]
InnerConnection::Postgres(ref mut conn) => { InnerConnection::Postgres(conn) => {
let query = crate::driver::sqlx_postgres::sqlx_query(&stmt); let query = crate::driver::sqlx_postgres::sqlx_query(&stmt);
crate::metric::metric!(self.metric_callback, &stmt, { crate::metric::metric!(self.metric_callback, &stmt, {
Self::map_err_ignore_not_found( Self::map_err_ignore_not_found(
query.fetch_one(&mut **conn).await.map(|row| Some(row.into())), query.fetch_one(conn).await.map(|row| Some(row.into())),
) )
}) })
} }
#[cfg(feature = "sqlx-sqlite")] #[cfg(feature = "sqlx-sqlite")]
InnerConnection::Sqlite(ref mut conn) => { InnerConnection::Sqlite(conn) => {
let query = crate::driver::sqlx_sqlite::sqlx_query(&stmt); let query = crate::driver::sqlx_sqlite::sqlx_query(&stmt);
crate::metric::metric!(self.metric_callback, &stmt, { crate::metric::metric!(self.metric_callback, &stmt, {
Self::map_err_ignore_not_found( Self::map_err_ignore_not_found(
query.fetch_one(&mut **conn).await.map(|row| Some(row.into())), query.fetch_one(conn).await.map(|row| Some(row.into())),
) )
}) })
} }
@ -419,33 +419,33 @@ impl ConnectionTrait for DatabaseTransaction {
match &mut *self.conn.lock().await { match &mut *self.conn.lock().await {
#[cfg(feature = "sqlx-mysql")] #[cfg(feature = "sqlx-mysql")]
InnerConnection::MySql(ref mut conn) => { InnerConnection::MySql(conn) => {
let query = crate::driver::sqlx_mysql::sqlx_query(&stmt); let query = crate::driver::sqlx_mysql::sqlx_query(&stmt);
crate::metric::metric!(self.metric_callback, &stmt, { crate::metric::metric!(self.metric_callback, &stmt, {
query query
.fetch_all(&mut **conn) .fetch_all(conn)
.await .await
.map(|rows| rows.into_iter().map(|r| r.into()).collect()) .map(|rows| rows.into_iter().map(|r| r.into()).collect())
.map_err(sqlx_error_to_query_err) .map_err(sqlx_error_to_query_err)
}) })
} }
#[cfg(feature = "sqlx-postgres")] #[cfg(feature = "sqlx-postgres")]
InnerConnection::Postgres(ref mut conn) => { InnerConnection::Postgres(conn) => {
let query = crate::driver::sqlx_postgres::sqlx_query(&stmt); let query = crate::driver::sqlx_postgres::sqlx_query(&stmt);
crate::metric::metric!(self.metric_callback, &stmt, { crate::metric::metric!(self.metric_callback, &stmt, {
query query
.fetch_all(&mut **conn) .fetch_all(conn)
.await .await
.map(|rows| rows.into_iter().map(|r| r.into()).collect()) .map(|rows| rows.into_iter().map(|r| r.into()).collect())
.map_err(sqlx_error_to_query_err) .map_err(sqlx_error_to_query_err)
}) })
} }
#[cfg(feature = "sqlx-sqlite")] #[cfg(feature = "sqlx-sqlite")]
InnerConnection::Sqlite(ref mut conn) => { InnerConnection::Sqlite(conn) => {
let query = crate::driver::sqlx_sqlite::sqlx_query(&stmt); let query = crate::driver::sqlx_sqlite::sqlx_query(&stmt);
crate::metric::metric!(self.metric_callback, &stmt, { crate::metric::metric!(self.metric_callback, &stmt, {
query query
.fetch_all(&mut **conn) .fetch_all(conn)
.await .await
.map(|rows| rows.into_iter().map(|r| r.into()).collect()) .map(|rows| rows.into_iter().map(|r| r.into()).collect())
.map_err(sqlx_error_to_query_err) .map_err(sqlx_error_to_query_err)

View File

@ -49,9 +49,9 @@ impl SqlxMySqlConnector {
.map_err(sqlx_error_to_conn_err)?; .map_err(sqlx_error_to_conn_err)?;
use sqlx::ConnectOptions; use sqlx::ConnectOptions;
if !options.sqlx_logging { if !options.sqlx_logging {
opt = opt.disable_statement_logging(); opt.disable_statement_logging();
} else { } else {
opt = opt.log_statements(options.sqlx_logging_level); opt.log_statements(options.sqlx_logging_level);
} }
match options.pool_options().connect_with(opt).await { match options.pool_options().connect_with(opt).await {
Ok(pool) => Ok(DatabaseConnection::SqlxMySqlPoolConnection( Ok(pool) => Ok(DatabaseConnection::SqlxMySqlPoolConnection(
@ -82,9 +82,9 @@ impl SqlxMySqlPoolConnection {
debug_print!("{}", stmt); debug_print!("{}", stmt);
let query = sqlx_query(&stmt); let query = sqlx_query(&stmt);
if let Ok(mut conn) = self.pool.acquire().await { if let Ok(conn) = &mut self.pool.acquire().await {
crate::metric::metric!(self.metric_callback, &stmt, { crate::metric::metric!(self.metric_callback, &stmt, {
match query.execute(&mut *conn).await { match query.execute(conn).await {
Ok(res) => Ok(res.into()), Ok(res) => Ok(res.into()),
Err(err) => Err(sqlx_error_to_exec_err(err)), Err(err) => Err(sqlx_error_to_exec_err(err)),
} }
@ -99,7 +99,7 @@ impl SqlxMySqlPoolConnection {
pub async fn execute_unprepared(&self, sql: &str) -> Result<ExecResult, DbErr> { pub async fn execute_unprepared(&self, sql: &str) -> Result<ExecResult, DbErr> {
debug_print!("{}", sql); debug_print!("{}", sql);
if let Ok(mut conn) = self.pool.acquire().await { if let Ok(conn) = &mut self.pool.acquire().await {
match conn.execute(sql).await { match conn.execute(sql).await {
Ok(res) => Ok(res.into()), Ok(res) => Ok(res.into()),
Err(err) => Err(sqlx_error_to_exec_err(err)), Err(err) => Err(sqlx_error_to_exec_err(err)),
@ -115,9 +115,9 @@ impl SqlxMySqlPoolConnection {
debug_print!("{}", stmt); debug_print!("{}", stmt);
let query = sqlx_query(&stmt); let query = sqlx_query(&stmt);
if let Ok(mut conn) = self.pool.acquire().await { if let Ok(conn) = &mut self.pool.acquire().await {
crate::metric::metric!(self.metric_callback, &stmt, { crate::metric::metric!(self.metric_callback, &stmt, {
match query.fetch_one(&mut *conn).await { match query.fetch_one(conn).await {
Ok(row) => Ok(Some(row.into())), Ok(row) => Ok(Some(row.into())),
Err(err) => match err { Err(err) => match err {
sqlx::Error::RowNotFound => Ok(None), sqlx::Error::RowNotFound => Ok(None),
@ -136,9 +136,9 @@ impl SqlxMySqlPoolConnection {
debug_print!("{}", stmt); debug_print!("{}", stmt);
let query = sqlx_query(&stmt); let query = sqlx_query(&stmt);
if let Ok(mut conn) = self.pool.acquire().await { if let Ok(conn) = &mut self.pool.acquire().await {
crate::metric::metric!(self.metric_callback, &stmt, { crate::metric::metric!(self.metric_callback, &stmt, {
match query.fetch_all(&mut *conn).await { match query.fetch_all(conn).await {
Ok(rows) => Ok(rows.into_iter().map(|r| r.into()).collect()), Ok(rows) => Ok(rows.into_iter().map(|r| r.into()).collect()),
Err(err) => Err(sqlx_error_to_query_err(err)), Err(err) => Err(sqlx_error_to_query_err(err)),
} }
@ -224,7 +224,7 @@ impl SqlxMySqlPoolConnection {
/// Checks if a connection to the database is still valid. /// Checks if a connection to the database is still valid.
pub async fn ping(&self) -> Result<(), DbErr> { pub async fn ping(&self) -> Result<(), DbErr> {
if let Ok(mut conn) = self.pool.acquire().await { if let Ok(conn) = &mut self.pool.acquire().await {
match conn.ping().await { match conn.ping().await {
Ok(_) => Ok(()), Ok(_) => Ok(()),
Err(err) => Err(sqlx_error_to_conn_err(err)), Err(err) => Err(sqlx_error_to_conn_err(err)),

View File

@ -49,9 +49,9 @@ impl SqlxPostgresConnector {
.map_err(sqlx_error_to_conn_err)?; .map_err(sqlx_error_to_conn_err)?;
use sqlx::ConnectOptions; use sqlx::ConnectOptions;
if !options.sqlx_logging { if !options.sqlx_logging {
opt = opt.disable_statement_logging(); opt.disable_statement_logging();
} else { } else {
opt = opt.log_statements(options.sqlx_logging_level); opt.log_statements(options.sqlx_logging_level);
} }
let set_search_path_sql = options let set_search_path_sql = options
.schema_search_path .schema_search_path
@ -97,9 +97,9 @@ impl SqlxPostgresPoolConnection {
debug_print!("{}", stmt); debug_print!("{}", stmt);
let query = sqlx_query(&stmt); let query = sqlx_query(&stmt);
if let Ok(mut conn) = self.pool.acquire().await { if let Ok(conn) = &mut self.pool.acquire().await {
crate::metric::metric!(self.metric_callback, &stmt, { crate::metric::metric!(self.metric_callback, &stmt, {
match query.execute(&mut *conn).await { match query.execute(conn).await {
Ok(res) => Ok(res.into()), Ok(res) => Ok(res.into()),
Err(err) => Err(sqlx_error_to_exec_err(err)), Err(err) => Err(sqlx_error_to_exec_err(err)),
} }
@ -114,7 +114,7 @@ impl SqlxPostgresPoolConnection {
pub async fn execute_unprepared(&self, sql: &str) -> Result<ExecResult, DbErr> { pub async fn execute_unprepared(&self, sql: &str) -> Result<ExecResult, DbErr> {
debug_print!("{}", sql); debug_print!("{}", sql);
if let Ok(mut conn) = self.pool.acquire().await { if let Ok(conn) = &mut self.pool.acquire().await {
match conn.execute(sql).await { match conn.execute(sql).await {
Ok(res) => Ok(res.into()), Ok(res) => Ok(res.into()),
Err(err) => Err(sqlx_error_to_exec_err(err)), Err(err) => Err(sqlx_error_to_exec_err(err)),
@ -130,9 +130,9 @@ impl SqlxPostgresPoolConnection {
debug_print!("{}", stmt); debug_print!("{}", stmt);
let query = sqlx_query(&stmt); let query = sqlx_query(&stmt);
if let Ok(mut conn) = self.pool.acquire().await { if let Ok(conn) = &mut self.pool.acquire().await {
crate::metric::metric!(self.metric_callback, &stmt, { crate::metric::metric!(self.metric_callback, &stmt, {
match query.fetch_one(&mut *conn).await { match query.fetch_one(conn).await {
Ok(row) => Ok(Some(row.into())), Ok(row) => Ok(Some(row.into())),
Err(err) => match err { Err(err) => match err {
sqlx::Error::RowNotFound => Ok(None), sqlx::Error::RowNotFound => Ok(None),
@ -151,9 +151,9 @@ impl SqlxPostgresPoolConnection {
debug_print!("{}", stmt); debug_print!("{}", stmt);
let query = sqlx_query(&stmt); let query = sqlx_query(&stmt);
if let Ok(mut conn) = self.pool.acquire().await { if let Ok(conn) = &mut self.pool.acquire().await {
crate::metric::metric!(self.metric_callback, &stmt, { crate::metric::metric!(self.metric_callback, &stmt, {
match query.fetch_all(&mut *conn).await { match query.fetch_all(conn).await {
Ok(rows) => Ok(rows.into_iter().map(|r| r.into()).collect()), Ok(rows) => Ok(rows.into_iter().map(|r| r.into()).collect()),
Err(err) => Err(sqlx_error_to_query_err(err)), Err(err) => Err(sqlx_error_to_query_err(err)),
} }
@ -239,7 +239,7 @@ impl SqlxPostgresPoolConnection {
/// Checks if a connection to the database is still valid. /// Checks if a connection to the database is still valid.
pub async fn ping(&self) -> Result<(), DbErr> { pub async fn ping(&self) -> Result<(), DbErr> {
if let Ok(mut conn) = self.pool.acquire().await { if let Ok(conn) = &mut self.pool.acquire().await {
match conn.ping().await { match conn.ping().await {
Ok(_) => Ok(()), Ok(_) => Ok(()),
Err(err) => Err(sqlx_error_to_conn_err(err)), Err(err) => Err(sqlx_error_to_conn_err(err)),

View File

@ -53,9 +53,9 @@ impl SqlxSqliteConnector {
} }
use sqlx::ConnectOptions; use sqlx::ConnectOptions;
if !options.sqlx_logging { if !options.sqlx_logging {
opt = opt.disable_statement_logging(); opt.disable_statement_logging();
} else { } else {
opt = opt.log_statements(options.sqlx_logging_level); opt.log_statements(options.sqlx_logging_level);
} }
if options.get_max_connections().is_none() { if options.get_max_connections().is_none() {
options.max_connections(1); options.max_connections(1);
@ -89,9 +89,9 @@ impl SqlxSqlitePoolConnection {
debug_print!("{}", stmt); debug_print!("{}", stmt);
let query = sqlx_query(&stmt); let query = sqlx_query(&stmt);
if let Ok(mut conn) = self.pool.acquire().await { if let Ok(conn) = &mut self.pool.acquire().await {
crate::metric::metric!(self.metric_callback, &stmt, { crate::metric::metric!(self.metric_callback, &stmt, {
match query.execute(&mut *conn).await { match query.execute(conn).await {
Ok(res) => Ok(res.into()), Ok(res) => Ok(res.into()),
Err(err) => Err(sqlx_error_to_exec_err(err)), Err(err) => Err(sqlx_error_to_exec_err(err)),
} }
@ -106,7 +106,7 @@ impl SqlxSqlitePoolConnection {
pub async fn execute_unprepared(&self, sql: &str) -> Result<ExecResult, DbErr> { pub async fn execute_unprepared(&self, sql: &str) -> Result<ExecResult, DbErr> {
debug_print!("{}", sql); debug_print!("{}", sql);
if let Ok(mut conn) = self.pool.acquire().await { if let Ok(conn) = &mut self.pool.acquire().await {
match conn.execute(sql).await { match conn.execute(sql).await {
Ok(res) => Ok(res.into()), Ok(res) => Ok(res.into()),
Err(err) => Err(sqlx_error_to_exec_err(err)), Err(err) => Err(sqlx_error_to_exec_err(err)),
@ -122,9 +122,9 @@ impl SqlxSqlitePoolConnection {
debug_print!("{}", stmt); debug_print!("{}", stmt);
let query = sqlx_query(&stmt); let query = sqlx_query(&stmt);
if let Ok(mut conn) = self.pool.acquire().await { if let Ok(conn) = &mut self.pool.acquire().await {
crate::metric::metric!(self.metric_callback, &stmt, { crate::metric::metric!(self.metric_callback, &stmt, {
match query.fetch_one(&mut *conn).await { match query.fetch_one(conn).await {
Ok(row) => Ok(Some(row.into())), Ok(row) => Ok(Some(row.into())),
Err(err) => match err { Err(err) => match err {
sqlx::Error::RowNotFound => Ok(None), sqlx::Error::RowNotFound => Ok(None),
@ -143,9 +143,9 @@ impl SqlxSqlitePoolConnection {
debug_print!("{}", stmt); debug_print!("{}", stmt);
let query = sqlx_query(&stmt); let query = sqlx_query(&stmt);
if let Ok(mut conn) = self.pool.acquire().await { if let Ok(conn) = &mut self.pool.acquire().await {
crate::metric::metric!(self.metric_callback, &stmt, { crate::metric::metric!(self.metric_callback, &stmt, {
match query.fetch_all(&mut *conn).await { match query.fetch_all(conn).await {
Ok(rows) => Ok(rows.into_iter().map(|r| r.into()).collect()), Ok(rows) => Ok(rows.into_iter().map(|r| r.into()).collect()),
Err(err) => Err(sqlx_error_to_query_err(err)), Err(err) => Err(sqlx_error_to_query_err(err)),
} }
@ -231,7 +231,7 @@ impl SqlxSqlitePoolConnection {
/// Checks if a connection to the database is still valid. /// Checks if a connection to the database is still valid.
pub async fn ping(&self) -> Result<(), DbErr> { pub async fn ping(&self) -> Result<(), DbErr> {
if let Ok(mut conn) = self.pool.acquire().await { if let Ok(conn) = &mut self.pool.acquire().await {
match conn.ping().await { match conn.ping().await {
Ok(_) => Ok(()), Ok(_) => Ok(()),
Err(err) => Err(sqlx_error_to_conn_err(err)), Err(err) => Err(sqlx_error_to_conn_err(err)),

View File

@ -347,7 +347,7 @@ where
mod tests { mod tests {
use sea_query::OnConflict; use sea_query::OnConflict;
use crate::tests_cfg::cake::{self}; use crate::tests_cfg::cake::{self, ActiveModel};
use crate::{ActiveValue, DbBackend, DbErr, EntityTrait, Insert, IntoActiveModel, QueryTrait}; use crate::{ActiveValue, DbBackend, DbErr, EntityTrait, Insert, IntoActiveModel, QueryTrait};
#[test] #[test]