Fix clippy warnings
This commit is contained in:
parent
4072e74284
commit
006d35313b
@ -247,20 +247,22 @@ impl DatabaseConnection {
|
||||
|
||||
impl DatabaseConnection {
|
||||
/// Sets a callback to metric this connection
|
||||
pub fn set_metric_callback<F>(&mut self, callback: F)
|
||||
pub fn set_metric_callback<F>(&mut self, _callback: F)
|
||||
where
|
||||
F: Fn(&crate::metric::Info<'_>) + Send + Sync + 'static,
|
||||
{
|
||||
match self {
|
||||
#[cfg(feature = "sqlx-mysql")]
|
||||
DatabaseConnection::SqlxMySqlPoolConnection(conn) => conn.set_metric_callback(callback),
|
||||
DatabaseConnection::SqlxMySqlPoolConnection(conn) => {
|
||||
conn.set_metric_callback(_callback)
|
||||
}
|
||||
#[cfg(feature = "sqlx-postgres")]
|
||||
DatabaseConnection::SqlxPostgresPoolConnection(conn) => {
|
||||
conn.set_metric_callback(callback)
|
||||
conn.set_metric_callback(_callback)
|
||||
}
|
||||
#[cfg(feature = "sqlx-sqlite")]
|
||||
DatabaseConnection::SqlxSqlitePoolConnection(conn) => {
|
||||
conn.set_metric_callback(callback)
|
||||
conn.set_metric_callback(_callback)
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
@ -120,11 +120,11 @@ impl QueryStream {
|
||||
stmt,
|
||||
conn,
|
||||
metric_callback,
|
||||
stream_builder: |conn, stmt, metric_callback| match conn {
|
||||
stream_builder: |conn, stmt, _metric_callback| match conn {
|
||||
#[cfg(feature = "sqlx-mysql")]
|
||||
InnerConnection::MySql(c) => {
|
||||
let query = crate::driver::sqlx_mysql::sqlx_query(stmt);
|
||||
crate::metric::metric_ok!(metric_callback, stmt, {
|
||||
crate::metric::metric_ok!(_metric_callback, stmt, {
|
||||
Box::pin(
|
||||
c.fetch(query)
|
||||
.map_ok(Into::into)
|
||||
@ -135,7 +135,7 @@ impl QueryStream {
|
||||
#[cfg(feature = "sqlx-postgres")]
|
||||
InnerConnection::Postgres(c) => {
|
||||
let query = crate::driver::sqlx_postgres::sqlx_query(stmt);
|
||||
crate::metric::metric_ok!(metric_callback, stmt, {
|
||||
crate::metric::metric_ok!(_metric_callback, stmt, {
|
||||
Box::pin(
|
||||
c.fetch(query)
|
||||
.map_ok(Into::into)
|
||||
@ -146,7 +146,7 @@ impl QueryStream {
|
||||
#[cfg(feature = "sqlx-sqlite")]
|
||||
InnerConnection::Sqlite(c) => {
|
||||
let query = crate::driver::sqlx_sqlite::sqlx_query(stmt);
|
||||
crate::metric::metric_ok!(metric_callback, stmt, {
|
||||
crate::metric::metric_ok!(_metric_callback, stmt, {
|
||||
Box::pin(
|
||||
c.fetch(query)
|
||||
.map_ok(Into::into)
|
||||
|
@ -44,13 +44,13 @@ impl<'a> TransactionStream<'a> {
|
||||
stmt,
|
||||
conn,
|
||||
metric_callback,
|
||||
stream_builder: |conn, stmt, metric_callback| {
|
||||
stream_builder: |conn, stmt, _metric_callback| {
|
||||
Box::pin(async move {
|
||||
match conn.deref_mut() {
|
||||
#[cfg(feature = "sqlx-mysql")]
|
||||
InnerConnection::MySql(c) => {
|
||||
let query = crate::driver::sqlx_mysql::sqlx_query(stmt);
|
||||
crate::metric::metric_ok!(metric_callback, stmt, {
|
||||
crate::metric::metric_ok!(_metric_callback, stmt, {
|
||||
Box::pin(
|
||||
c.fetch(query)
|
||||
.map_ok(Into::into)
|
||||
@ -62,7 +62,7 @@ impl<'a> TransactionStream<'a> {
|
||||
#[cfg(feature = "sqlx-postgres")]
|
||||
InnerConnection::Postgres(c) => {
|
||||
let query = crate::driver::sqlx_postgres::sqlx_query(stmt);
|
||||
crate::metric::metric_ok!(metric_callback, stmt, {
|
||||
crate::metric::metric_ok!(_metric_callback, stmt, {
|
||||
Box::pin(
|
||||
c.fetch(query)
|
||||
.map_ok(Into::into)
|
||||
@ -74,7 +74,7 @@ impl<'a> TransactionStream<'a> {
|
||||
#[cfg(feature = "sqlx-sqlite")]
|
||||
InnerConnection::Sqlite(c) => {
|
||||
let query = crate::driver::sqlx_sqlite::sqlx_query(stmt);
|
||||
crate::metric::metric_ok!(metric_callback, stmt, {
|
||||
crate::metric::metric_ok!(_metric_callback, stmt, {
|
||||
Box::pin(
|
||||
c.fetch(query)
|
||||
.map_ok(Into::into)
|
||||
|
@ -28,6 +28,7 @@ where
|
||||
S: SelectorTrait,
|
||||
{
|
||||
stmt: Statement,
|
||||
#[allow(dead_code)]
|
||||
selector: S,
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ use std::{sync::Arc, time::Duration};
|
||||
|
||||
pub(crate) type Callback = Arc<dyn Fn(&Info<'_>) + Send + Sync>;
|
||||
|
||||
#[allow(unused_imports)]
|
||||
pub(crate) use inner::{metric, metric_ok};
|
||||
|
||||
#[derive(Debug)]
|
||||
@ -16,6 +17,7 @@ pub struct Info<'a> {
|
||||
}
|
||||
|
||||
mod inner {
|
||||
#[allow(unused_macros)]
|
||||
macro_rules! metric {
|
||||
($metric_callback:expr, $stmt:expr, $code:block) => {{
|
||||
let _start = std::time::SystemTime::now();
|
||||
@ -32,6 +34,7 @@ mod inner {
|
||||
}};
|
||||
}
|
||||
pub(crate) use metric;
|
||||
#[allow(unused_macros)]
|
||||
macro_rules! metric_ok {
|
||||
($metric_callback:expr, $stmt:expr, $code:block) => {{
|
||||
let _start = std::time::SystemTime::now();
|
||||
|
@ -401,15 +401,15 @@ mod tests {
|
||||
color: None,
|
||||
tea: None,
|
||||
};
|
||||
let select = active_enum_model.find_related(ActiveEnumChild);
|
||||
let _select = active_enum_model.find_related(ActiveEnumChild);
|
||||
#[cfg(any(feature = "sqlx-mysql", feature = "sqlx-sqlite"))]
|
||||
{
|
||||
assert_eq!(
|
||||
select.build(DbBackend::MySql).to_string(),
|
||||
select.build(DbBackend::Sqlite).to_string(),
|
||||
_select.build(DbBackend::MySql).to_string(),
|
||||
_select.build(DbBackend::Sqlite).to_string(),
|
||||
);
|
||||
assert_eq!(
|
||||
select.build(DbBackend::MySql).to_string(),
|
||||
_select.build(DbBackend::MySql).to_string(),
|
||||
[
|
||||
"SELECT `active_enum_child`.`id`, `active_enum_child`.`parent_id`, `active_enum_child`.`category`, `active_enum_child`.`color`, `active_enum_child`.`tea`",
|
||||
"FROM `active_enum_child`",
|
||||
@ -421,7 +421,7 @@ mod tests {
|
||||
}
|
||||
#[cfg(feature = "sqlx-postgres")]
|
||||
assert_eq!(
|
||||
select.build(DbBackend::Postgres).to_string(),
|
||||
_select.build(DbBackend::Postgres).to_string(),
|
||||
[
|
||||
r#"SELECT "active_enum_child"."id", "active_enum_child"."parent_id", "active_enum_child"."category", "active_enum_child"."color", CAST("active_enum_child"."tea" AS text)"#,
|
||||
r#"FROM "public"."active_enum_child""#,
|
||||
@ -431,15 +431,15 @@ mod tests {
|
||||
.join(" ")
|
||||
);
|
||||
|
||||
let select = ActiveEnum::find().find_also_related(ActiveEnumChild);
|
||||
let _select = ActiveEnum::find().find_also_related(ActiveEnumChild);
|
||||
#[cfg(any(feature = "sqlx-mysql", feature = "sqlx-sqlite"))]
|
||||
{
|
||||
assert_eq!(
|
||||
select.build(DbBackend::MySql).to_string(),
|
||||
select.build(DbBackend::Sqlite).to_string(),
|
||||
_select.build(DbBackend::MySql).to_string(),
|
||||
_select.build(DbBackend::Sqlite).to_string(),
|
||||
);
|
||||
assert_eq!(
|
||||
select
|
||||
_select
|
||||
.build(DbBackend::MySql)
|
||||
.to_string(),
|
||||
[
|
||||
@ -453,7 +453,7 @@ mod tests {
|
||||
}
|
||||
#[cfg(feature = "sqlx-postgres")]
|
||||
assert_eq!(
|
||||
select
|
||||
_select
|
||||
.build(DbBackend::Postgres)
|
||||
.to_string(),
|
||||
[
|
||||
@ -474,15 +474,15 @@ mod tests {
|
||||
color: None,
|
||||
tea: None,
|
||||
};
|
||||
let select = active_enum_model.find_linked(active_enum::ActiveEnumChildLink);
|
||||
let _select = active_enum_model.find_linked(active_enum::ActiveEnumChildLink);
|
||||
#[cfg(any(feature = "sqlx-mysql", feature = "sqlx-sqlite"))]
|
||||
{
|
||||
assert_eq!(
|
||||
select.build(DbBackend::MySql).to_string(),
|
||||
select.build(DbBackend::Sqlite).to_string(),
|
||||
_select.build(DbBackend::MySql).to_string(),
|
||||
_select.build(DbBackend::Sqlite).to_string(),
|
||||
);
|
||||
assert_eq!(
|
||||
select.build(DbBackend::MySql).to_string(),
|
||||
_select.build(DbBackend::MySql).to_string(),
|
||||
[
|
||||
"SELECT `active_enum_child`.`id`, `active_enum_child`.`parent_id`, `active_enum_child`.`category`, `active_enum_child`.`color`, `active_enum_child`.`tea`",
|
||||
"FROM `active_enum_child`",
|
||||
@ -494,7 +494,7 @@ mod tests {
|
||||
}
|
||||
#[cfg(feature = "sqlx-postgres")]
|
||||
assert_eq!(
|
||||
select.build(DbBackend::Postgres).to_string(),
|
||||
_select.build(DbBackend::Postgres).to_string(),
|
||||
[
|
||||
r#"SELECT "active_enum_child"."id", "active_enum_child"."parent_id", "active_enum_child"."category", "active_enum_child"."color", CAST("active_enum_child"."tea" AS text)"#,
|
||||
r#"FROM "public"."active_enum_child""#,
|
||||
@ -504,15 +504,15 @@ mod tests {
|
||||
.join(" ")
|
||||
);
|
||||
|
||||
let select = ActiveEnum::find().find_also_linked(active_enum::ActiveEnumChildLink);
|
||||
let _select = ActiveEnum::find().find_also_linked(active_enum::ActiveEnumChildLink);
|
||||
#[cfg(any(feature = "sqlx-mysql", feature = "sqlx-sqlite"))]
|
||||
{
|
||||
assert_eq!(
|
||||
select.build(DbBackend::MySql).to_string(),
|
||||
select.build(DbBackend::Sqlite).to_string(),
|
||||
_select.build(DbBackend::MySql).to_string(),
|
||||
_select.build(DbBackend::Sqlite).to_string(),
|
||||
);
|
||||
assert_eq!(
|
||||
select
|
||||
_select
|
||||
.build(DbBackend::MySql)
|
||||
.to_string(),
|
||||
[
|
||||
@ -526,7 +526,7 @@ mod tests {
|
||||
}
|
||||
#[cfg(feature = "sqlx-postgres")]
|
||||
assert_eq!(
|
||||
select
|
||||
_select
|
||||
.build(DbBackend::Postgres)
|
||||
.to_string(),
|
||||
[
|
||||
@ -548,15 +548,15 @@ mod tests {
|
||||
color: None,
|
||||
tea: None,
|
||||
};
|
||||
let select = active_enum_child_model.find_related(ActiveEnum);
|
||||
let _select = active_enum_child_model.find_related(ActiveEnum);
|
||||
#[cfg(any(feature = "sqlx-mysql", feature = "sqlx-sqlite"))]
|
||||
{
|
||||
assert_eq!(
|
||||
select.build(DbBackend::MySql).to_string(),
|
||||
select.build(DbBackend::Sqlite).to_string(),
|
||||
_select.build(DbBackend::MySql).to_string(),
|
||||
_select.build(DbBackend::Sqlite).to_string(),
|
||||
);
|
||||
assert_eq!(
|
||||
select.build(DbBackend::MySql).to_string(),
|
||||
_select.build(DbBackend::MySql).to_string(),
|
||||
[
|
||||
"SELECT `active_enum`.`id`, `active_enum`.`category`, `active_enum`.`color`, `active_enum`.`tea`",
|
||||
"FROM `active_enum`",
|
||||
@ -568,7 +568,7 @@ mod tests {
|
||||
}
|
||||
#[cfg(feature = "sqlx-postgres")]
|
||||
assert_eq!(
|
||||
select.build(DbBackend::Postgres).to_string(),
|
||||
_select.build(DbBackend::Postgres).to_string(),
|
||||
[
|
||||
r#"SELECT "active_enum"."id", "active_enum"."category", "active_enum"."color", CAST("active_enum"."tea" AS text)"#,
|
||||
r#"FROM "public"."active_enum""#,
|
||||
@ -578,15 +578,15 @@ mod tests {
|
||||
.join(" ")
|
||||
);
|
||||
|
||||
let select = ActiveEnumChild::find().find_also_related(ActiveEnum);
|
||||
let _select = ActiveEnumChild::find().find_also_related(ActiveEnum);
|
||||
#[cfg(any(feature = "sqlx-mysql", feature = "sqlx-sqlite"))]
|
||||
{
|
||||
assert_eq!(
|
||||
select.build(DbBackend::MySql).to_string(),
|
||||
select.build(DbBackend::Sqlite).to_string(),
|
||||
_select.build(DbBackend::MySql).to_string(),
|
||||
_select.build(DbBackend::Sqlite).to_string(),
|
||||
);
|
||||
assert_eq!(
|
||||
select
|
||||
_select
|
||||
.build(DbBackend::MySql)
|
||||
.to_string(),
|
||||
[
|
||||
@ -600,7 +600,7 @@ mod tests {
|
||||
}
|
||||
#[cfg(feature = "sqlx-postgres")]
|
||||
assert_eq!(
|
||||
select
|
||||
_select
|
||||
.build(DbBackend::Postgres)
|
||||
.to_string(),
|
||||
[
|
||||
@ -622,15 +622,15 @@ mod tests {
|
||||
color: None,
|
||||
tea: None,
|
||||
};
|
||||
let select = active_enum_child_model.find_linked(active_enum_child::ActiveEnumLink);
|
||||
let _select = active_enum_child_model.find_linked(active_enum_child::ActiveEnumLink);
|
||||
#[cfg(any(feature = "sqlx-mysql", feature = "sqlx-sqlite"))]
|
||||
{
|
||||
assert_eq!(
|
||||
select.build(DbBackend::MySql).to_string(),
|
||||
select.build(DbBackend::Sqlite).to_string(),
|
||||
_select.build(DbBackend::MySql).to_string(),
|
||||
_select.build(DbBackend::Sqlite).to_string(),
|
||||
);
|
||||
assert_eq!(
|
||||
select.build(DbBackend::MySql).to_string(),
|
||||
_select.build(DbBackend::MySql).to_string(),
|
||||
[
|
||||
"SELECT `active_enum`.`id`, `active_enum`.`category`, `active_enum`.`color`, `active_enum`.`tea`",
|
||||
"FROM `active_enum`",
|
||||
@ -642,7 +642,7 @@ mod tests {
|
||||
}
|
||||
#[cfg(feature = "sqlx-postgres")]
|
||||
assert_eq!(
|
||||
select.build(DbBackend::Postgres).to_string(),
|
||||
_select.build(DbBackend::Postgres).to_string(),
|
||||
[
|
||||
r#"SELECT "active_enum"."id", "active_enum"."category", "active_enum"."color", CAST("active_enum"."tea" AS text)"#,
|
||||
r#"FROM "public"."active_enum""#,
|
||||
@ -652,15 +652,15 @@ mod tests {
|
||||
.join(" ")
|
||||
);
|
||||
|
||||
let select = ActiveEnumChild::find().find_also_linked(active_enum_child::ActiveEnumLink);
|
||||
let _select = ActiveEnumChild::find().find_also_linked(active_enum_child::ActiveEnumLink);
|
||||
#[cfg(any(feature = "sqlx-mysql", feature = "sqlx-sqlite"))]
|
||||
{
|
||||
assert_eq!(
|
||||
select.build(DbBackend::MySql).to_string(),
|
||||
select.build(DbBackend::Sqlite).to_string(),
|
||||
_select.build(DbBackend::MySql).to_string(),
|
||||
_select.build(DbBackend::Sqlite).to_string(),
|
||||
);
|
||||
assert_eq!(
|
||||
select
|
||||
_select
|
||||
.build(DbBackend::MySql)
|
||||
.to_string(),
|
||||
[
|
||||
@ -674,7 +674,7 @@ mod tests {
|
||||
}
|
||||
#[cfg(feature = "sqlx-postgres")]
|
||||
assert_eq!(
|
||||
select
|
||||
_select
|
||||
.build(DbBackend::Postgres)
|
||||
.to_string(),
|
||||
[
|
||||
|
@ -71,6 +71,7 @@ pub async fn left_join() {
|
||||
.await
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
assert_eq!(result.name.as_str(), "Baker 1");
|
||||
assert_eq!(result.bakery_name, Some("SeaSide Bakery".to_string()));
|
||||
|
||||
let select = baker::Entity::find()
|
||||
@ -340,6 +341,7 @@ pub async fn group_by() {
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(result.name.as_str(), "Kate");
|
||||
assert_eq!(result.number_orders, Some(2));
|
||||
assert_eq!(
|
||||
result.total_spent,
|
||||
|
Loading…
x
Reference in New Issue
Block a user