From 2bb46edfdfbb5f2e0971ccb0add42dd0689e1625 Mon Sep 17 00:00:00 2001 From: shogo-nakano-desu <61229807+shogo-nakano-desu@users.noreply.github.com> Date: Wed, 10 Jan 2024 19:20:23 +0900 Subject: [PATCH 01/20] chore: add clippy config file --- clippy.toml | 1 + 1 file changed, 1 insertion(+) create mode 100644 clippy.toml diff --git a/clippy.toml b/clippy.toml new file mode 100644 index 000000000..154626ef4 --- /dev/null +++ b/clippy.toml @@ -0,0 +1 @@ +allow-unwrap-in-tests = true From 0536427335bbf1b7d13f730ac6f3565c3c19d648 Mon Sep 17 00:00:00 2001 From: shogo-nakano-desu <61229807+shogo-nakano-desu@users.noreply.github.com> Date: Wed, 10 Jan 2024 19:21:00 +0900 Subject: [PATCH 02/20] refactor: fix clippy errors and wornings of runtime-async-std-native-tls,sqlx-all --- sea-orm-macros/src/strum/helpers/mod.rs | 1 - src/driver/mock.rs | 4 ++++ src/query/combine.rs | 1 - src/query/mod.rs | 2 +- src/query/select.rs | 2 +- tests/active_enum_tests.rs | 2 +- tests/common/features/json_vec.rs | 4 ++-- tests/common/setup/mod.rs | 3 +-- tests/connection_tests.rs | 4 ++-- tests/cursor_tests.rs | 6 +++--- tests/empty_insert_tests.rs | 4 ++-- tests/loader_tests.rs | 2 +- tests/pi_tests.rs | 2 +- tests/relational_tests.rs | 6 +++--- tests/returning_tests.rs | 4 ++-- tests/time_crate_tests.rs | 4 ++-- tests/transaction_tests.rs | 2 +- 17 files changed, 27 insertions(+), 26 deletions(-) diff --git a/sea-orm-macros/src/strum/helpers/mod.rs b/sea-orm-macros/src/strum/helpers/mod.rs index 77049eb4b..5f076579b 100644 --- a/sea-orm-macros/src/strum/helpers/mod.rs +++ b/sea-orm-macros/src/strum/helpers/mod.rs @@ -1,4 +1,3 @@ -pub use self::case_style::CaseStyleHelpers; pub use self::type_props::HasTypeProperties; pub use self::variant_props::HasStrumVariantProperties; diff --git a/src/driver/mock.rs b/src/driver/mock.rs index af3145cbb..716173b38 100644 --- a/src/driver/mock.rs +++ b/src/driver/mock.rs @@ -100,6 +100,8 @@ impl MockDatabaseConnector { } impl MockDatabaseConnection { + /// # Panics + /// /// Create a connection to the [MockDatabase] pub fn new(m: M) -> Self where @@ -116,6 +118,8 @@ impl MockDatabaseConnection { &self.mocker } + /// # Panics + /// /// Get the [DatabaseBackend](crate::DatabaseBackend) being used by the [MockDatabase] pub fn get_database_backend(&self) -> DbBackend { self.mocker diff --git a/src/query/combine.rs b/src/query/combine.rs index 61d957f74..0f2d0290c 100644 --- a/src/query/combine.rs +++ b/src/query/combine.rs @@ -2,7 +2,6 @@ use crate::{ ColumnTrait, EntityTrait, IdenStatic, Iterable, QueryTrait, Select, SelectTwo, SelectTwoMany, }; use core::marker::PhantomData; -pub use sea_query::JoinType; use sea_query::{Alias, ColumnRef, Iden, Order, SeaRc, SelectExpr, SelectStatement, SimpleExpr}; macro_rules! select_def { diff --git a/src/query/mod.rs b/src/query/mod.rs index 559eba176..fae61a659 100644 --- a/src/query/mod.rs +++ b/src/query/mod.rs @@ -15,7 +15,7 @@ pub use combine::{SelectA, SelectB}; pub use delete::*; pub use helper::*; pub use insert::*; -pub use join::*; + #[cfg(feature = "with-json")] pub use json::*; pub use loader::*; diff --git a/src/query/select.rs b/src/query/select.rs index f747fb582..2da17a108 100644 --- a/src/query/select.rs +++ b/src/query/select.rs @@ -1,7 +1,7 @@ use crate::{ColumnTrait, EntityTrait, Iterable, QueryFilter, QueryOrder, QuerySelect, QueryTrait}; use core::fmt::Debug; use core::marker::PhantomData; -pub use sea_query::JoinType; + use sea_query::{Expr, IntoColumnRef, SelectStatement, SimpleExpr}; /// Defines a structure to perform select operations diff --git a/tests/active_enum_tests.rs b/tests/active_enum_tests.rs index 1a38f3b71..1edb717b8 100644 --- a/tests/active_enum_tests.rs +++ b/tests/active_enum_tests.rs @@ -8,7 +8,7 @@ use sea_orm::{ entity::prelude::*, entity::*, sea_query::{BinOper, Expr}, - ActiveEnum as ActiveEnumTrait, DatabaseConnection, QueryTrait, + ActiveEnum as ActiveEnumTrait, DatabaseConnection, }; #[sea_orm_macros::test] diff --git a/tests/common/features/json_vec.rs b/tests/common/features/json_vec.rs index 5eb623496..b86eaf20e 100644 --- a/tests/common/features/json_vec.rs +++ b/tests/common/features/json_vec.rs @@ -23,9 +23,9 @@ impl TryGetableFromJson for StringVec {} impl From for Value { fn from(source: StringVec) -> Self { sea_orm::Value::Json( - serde_json::to_value(&source) + serde_json::to_value(source) .ok() - .map(|s| std::boxed::Box::new(s)), + .map(std::boxed::Box::new), ) } } diff --git a/tests/common/setup/mod.rs b/tests/common/setup/mod.rs index 2cdc00d21..a1f91d79b 100644 --- a/tests/common/setup/mod.rs +++ b/tests/common/setup/mod.rs @@ -74,8 +74,7 @@ pub async fn tear_down(base_url: &str, db_name: &str) { format!("DROP DATABASE IF EXISTS \"{db_name}\";"), )) .await; - } else { - }; + } ; } pub async fn create_enum( diff --git a/tests/connection_tests.rs b/tests/connection_tests.rs index e5966d106..d3d08bbe3 100644 --- a/tests/connection_tests.rs +++ b/tests/connection_tests.rs @@ -1,8 +1,8 @@ pub mod common; pub use common::{bakery_chain::*, setup::*, TestContext}; -use pretty_assertions::assert_eq; -use sea_orm::prelude::*; + + #[sea_orm_macros::test] #[cfg(any( diff --git a/tests/cursor_tests.rs b/tests/cursor_tests.rs index ef8280573..851427cf3 100644 --- a/tests/cursor_tests.rs +++ b/tests/cursor_tests.rs @@ -3,7 +3,7 @@ pub mod common; pub use common::{features::*, setup::*, TestContext}; use pretty_assertions::assert_eq; use sea_orm::{ - entity::prelude::*, DerivePartialModel, FromQueryResult, QueryOrder, QuerySelect, Set, + entity::prelude::*, DerivePartialModel, FromQueryResult, QuerySelect, Set, }; use serde_json::json; @@ -281,7 +281,7 @@ pub async fn cursor_pagination(db: &DatabaseConnection) -> Result<(), DbErr> { } use common::bakery_chain::{ - baker, bakery, cake, cakes_bakers, schema, Baker, Bakery, Cake, CakesBakers, + baker, bakery, cake, cakes_bakers, Baker, Bakery, Cake, CakesBakers, }; fn bakery(i: i32) -> bakery::Model { @@ -318,7 +318,7 @@ fn cakebaker(cake: char, baker: char) -> CakeBakerlite { } pub async fn create_baker_cake(db: &DatabaseConnection) -> Result<(), DbErr> { - use sea_orm::IntoActiveModel; + let mut bakeries: Vec = vec![]; // bakeries named from 1 to 10 diff --git a/tests/empty_insert_tests.rs b/tests/empty_insert_tests.rs index ea61a37fb..216baacc9 100644 --- a/tests/empty_insert_tests.rs +++ b/tests/empty_insert_tests.rs @@ -9,7 +9,7 @@ pub use sea_orm::{ pub use crud::*; // use common::bakery_chain::*; use sea_orm::{DbConn, TryInsertResult}; -use sea_query::OnConflict; + #[sea_orm_macros::test] #[cfg(any( @@ -38,7 +38,7 @@ pub async fn test(db: &DbConn) { assert!(matches!(res, Ok(TryInsertResult::Inserted(_)))); - let double_seaside_bakery = bakery::ActiveModel { + let _double_seaside_bakery = bakery::ActiveModel { name: Set("SeaSide Bakery".to_owned()), profit_margin: Set(10.4), id: Set(1), diff --git a/tests/loader_tests.rs b/tests/loader_tests.rs index 67341fdc6..e55a0666f 100644 --- a/tests/loader_tests.rs +++ b/tests/loader_tests.rs @@ -1,7 +1,7 @@ pub mod common; pub use common::{bakery_chain::*, setup::*, TestContext}; -use sea_orm::{entity::*, query::*, DbConn, DbErr, RuntimeErr}; +use sea_orm::{entity::*, DbConn, DbErr}; #[sea_orm_macros::test] #[cfg(any( diff --git a/tests/pi_tests.rs b/tests/pi_tests.rs index 0d344ceee..4362cd0b9 100644 --- a/tests/pi_tests.rs +++ b/tests/pi_tests.rs @@ -1,6 +1,6 @@ pub mod common; -use common::{features::*, TestContext}; +use common::{features::*}; use pretty_assertions::assert_eq; use rust_decimal_macros::dec; use sea_orm::{entity::prelude::*, entity::*, DatabaseConnection}; diff --git a/tests/relational_tests.rs b/tests/relational_tests.rs index c8c41b17a..0661c05ba 100644 --- a/tests/relational_tests.rs +++ b/tests/relational_tests.rs @@ -2,11 +2,11 @@ pub mod common; pub use chrono::offset::Utc; pub use common::{bakery_chain::*, setup::*, TestContext}; -use pretty_assertions::assert_eq; + pub use rust_decimal::prelude::*; pub use rust_decimal_macros::dec; -use sea_orm::{entity::*, query::*, DbErr, DerivePartialModel, FromQueryResult}; -use sea_query::{Expr, Func, SimpleExpr}; + + pub use uuid::Uuid; // Run the test locally: diff --git a/tests/returning_tests.rs b/tests/returning_tests.rs index bcdcc38d6..509bbb3c1 100644 --- a/tests/returning_tests.rs +++ b/tests/returning_tests.rs @@ -1,9 +1,9 @@ pub mod common; pub use common::{bakery_chain::*, setup::*, TestContext}; -use sea_orm::{entity::prelude::*, IntoActiveModel}; + pub use sea_query::{Expr, Query}; -use serde_json::json; + #[sea_orm_macros::test] #[cfg(any( diff --git a/tests/time_crate_tests.rs b/tests/time_crate_tests.rs index 6a940330f..0f40de0a7 100644 --- a/tests/time_crate_tests.rs +++ b/tests/time_crate_tests.rs @@ -2,7 +2,7 @@ pub mod common; pub use common::{features::*, setup::*, TestContext}; use pretty_assertions::assert_eq; use sea_orm::{entity::prelude::*, DatabaseConnection, IntoActiveModel}; -use serde_json::json; + use time::macros::{date, time}; #[sea_orm_macros::test] @@ -40,7 +40,7 @@ pub async fn create_transaction_log(db: &DatabaseConnection) -> Result<(), DbErr Some(transaction_log.clone()) ); - let json = TransactionLog::find().into_json().one(db).await?.unwrap(); + let _json = TransactionLog::find().into_json().one(db).await?.unwrap(); #[cfg(feature = "sqlx-postgres")] assert_eq!( diff --git a/tests/transaction_tests.rs b/tests/transaction_tests.rs index ffc937a6d..dfcb95666 100644 --- a/tests/transaction_tests.rs +++ b/tests/transaction_tests.rs @@ -2,7 +2,7 @@ pub mod common; pub use common::{bakery_chain::*, setup::*, TestContext}; use pretty_assertions::assert_eq; -use sea_orm::{prelude::*, AccessMode, DatabaseTransaction, IsolationLevel, Set, TransactionTrait}; +use sea_orm::{prelude::*, DatabaseTransaction, Set}; #[sea_orm_macros::test] #[cfg(any( From 26089f24c1a97ddccee8ff0a022ec33d2452a2b0 Mon Sep 17 00:00:00 2001 From: shogo-nakano-desu <61229807+shogo-nakano-desu@users.noreply.github.com> Date: Wed, 10 Jan 2024 20:56:34 +0900 Subject: [PATCH 03/20] refactor: fix clippy errors and wornings of sqlx-sqlite, sqlx-mysql, sqlx-postgres --- src/query/mod.rs | 1 - src/query/select.rs | 1 - tests/active_enum_tests.rs | 19 +++++++++++-------- tests/connection_tests.rs | 4 ++-- tests/cursor_tests.rs | 11 ++++------- tests/empty_insert_tests.rs | 1 - tests/loader_tests.rs | 2 +- tests/pi_tests.rs | 2 +- tests/relational_tests.rs | 6 +++--- tests/returning_tests.rs | 6 +++--- tests/time_crate_tests.rs | 4 ++-- tests/transaction_tests.rs | 2 +- 12 files changed, 28 insertions(+), 31 deletions(-) diff --git a/src/query/mod.rs b/src/query/mod.rs index fae61a659..227ba48c0 100644 --- a/src/query/mod.rs +++ b/src/query/mod.rs @@ -15,7 +15,6 @@ pub use combine::{SelectA, SelectB}; pub use delete::*; pub use helper::*; pub use insert::*; - #[cfg(feature = "with-json")] pub use json::*; pub use loader::*; diff --git a/src/query/select.rs b/src/query/select.rs index 2da17a108..4ac04aeb9 100644 --- a/src/query/select.rs +++ b/src/query/select.rs @@ -1,7 +1,6 @@ use crate::{ColumnTrait, EntityTrait, Iterable, QueryFilter, QueryOrder, QuerySelect, QueryTrait}; use core::fmt::Debug; use core::marker::PhantomData; - use sea_query::{Expr, IntoColumnRef, SelectStatement, SimpleExpr}; /// Defines a structure to perform select operations diff --git a/tests/active_enum_tests.rs b/tests/active_enum_tests.rs index 1edb717b8..81daddd60 100644 --- a/tests/active_enum_tests.rs +++ b/tests/active_enum_tests.rs @@ -1,9 +1,10 @@ pub mod common; -use active_enum::Entity as ActiveEnum; -use active_enum_child::Entity as ActiveEnumChild; +use active_enum::Entity as ActiveEnumEntity; pub use common::{features::*, setup::*, TestContext}; use pretty_assertions::assert_eq; +#[cfg(feature = "sqlx-postgres")] +use sea_orm::QueryTrait; use sea_orm::{ entity::prelude::*, entity::*, @@ -146,6 +147,7 @@ pub async fn insert_active_enum(db: &DatabaseConnection) -> Result<(), DbErr> { let select_with_tea_not_in = Entity::find() .filter(Column::Tea.is_not_null()) .filter(Column::Tea.is_not_in([Tea::BreakfastTea])); + #[cfg(feature = "sqlx-postgres")] assert_eq!( select_with_tea_not_in @@ -162,6 +164,7 @@ pub async fn insert_active_enum(db: &DatabaseConnection) -> Result<(), DbErr> { ] .join(" ") ); + assert_eq!(model, select_with_tea_not_in.one(db).await?.unwrap()); let res = model.delete(db).await?; @@ -338,7 +341,7 @@ pub async fn find_related_active_enum(db: &DatabaseConnection) -> Result<(), DbE }] ); assert_eq!( - ActiveEnum::find() + ActiveEnumEntity::find() .find_with_related(ActiveEnumChild) .all(db) .await?, @@ -359,7 +362,7 @@ pub async fn find_related_active_enum(db: &DatabaseConnection) -> Result<(), DbE )] ); assert_eq!( - ActiveEnum::find() + ActiveEnumEntity::find() .find_also_related(ActiveEnumChild) .all(db) .await?, @@ -464,7 +467,7 @@ pub async fn find_linked_active_enum(db: &DatabaseConnection) -> Result<(), DbEr }] ); assert_eq!( - ActiveEnum::find() + ActiveEnumEntity::find() .find_also_linked(active_enum::ActiveEnumChildLink) .all(db) .await?, @@ -485,7 +488,7 @@ pub async fn find_linked_active_enum(db: &DatabaseConnection) -> Result<(), DbEr )] ); assert_eq!( - ActiveEnum::find() + ActiveEnumEntity::find() .find_with_linked(active_enum::ActiveEnumChildLink) .all(db) .await?, @@ -620,7 +623,7 @@ mod tests { .join(" ") ); - let _select = ActiveEnum::find().find_also_related(ActiveEnumChild); + let _select = ActiveEnumEntity::find().find_also_related(ActiveEnumChild); #[cfg(any(feature = "sqlx-mysql", feature = "sqlx-sqlite"))] { assert_eq!( @@ -707,7 +710,7 @@ mod tests { .join(" ") ); - let _select = ActiveEnum::find().find_also_linked(active_enum::ActiveEnumChildLink); + let _select = ActiveEnumEntity::find().find_also_linked(active_enum::ActiveEnumChildLink); #[cfg(any(feature = "sqlx-mysql", feature = "sqlx-sqlite"))] { assert_eq!( diff --git a/tests/connection_tests.rs b/tests/connection_tests.rs index d3d08bbe3..e5966d106 100644 --- a/tests/connection_tests.rs +++ b/tests/connection_tests.rs @@ -1,8 +1,8 @@ pub mod common; pub use common::{bakery_chain::*, setup::*, TestContext}; - - +use pretty_assertions::assert_eq; +use sea_orm::prelude::*; #[sea_orm_macros::test] #[cfg(any( diff --git a/tests/cursor_tests.rs b/tests/cursor_tests.rs index 851427cf3..6b90c34f4 100644 --- a/tests/cursor_tests.rs +++ b/tests/cursor_tests.rs @@ -2,9 +2,7 @@ pub mod common; pub use common::{features::*, setup::*, TestContext}; use pretty_assertions::assert_eq; -use sea_orm::{ - entity::prelude::*, DerivePartialModel, FromQueryResult, QuerySelect, Set, -}; +use sea_orm::{entity::prelude::*, DerivePartialModel, FromQueryResult, QuerySelect, Set}; use serde_json::json; #[sea_orm_macros::test] @@ -18,7 +16,7 @@ async fn main() -> Result<(), DbErr> { create_tables(&ctx.db).await?; create_insert_default(&ctx.db).await?; cursor_pagination(&ctx.db).await?; - schema::create_tables(&ctx.db).await?; + bakery_chain_schema::create_tables(&ctx.db).await?; create_baker_cake(&ctx.db).await?; cursor_related_pagination(&ctx.db).await?; ctx.delete().await; @@ -281,7 +279,8 @@ pub async fn cursor_pagination(db: &DatabaseConnection) -> Result<(), DbErr> { } use common::bakery_chain::{ - baker, bakery, cake, cakes_bakers, Baker, Bakery, Cake, CakesBakers, + baker, bakery, cake, cakes_bakers, schema as bakery_chain_schema, Baker, Bakery, Cake, + CakesBakers, }; fn bakery(i: i32) -> bakery::Model { @@ -318,8 +317,6 @@ fn cakebaker(cake: char, baker: char) -> CakeBakerlite { } pub async fn create_baker_cake(db: &DatabaseConnection) -> Result<(), DbErr> { - - let mut bakeries: Vec = vec![]; // bakeries named from 1 to 10 for i in 1..=10 { diff --git a/tests/empty_insert_tests.rs b/tests/empty_insert_tests.rs index 216baacc9..6bc01f3a1 100644 --- a/tests/empty_insert_tests.rs +++ b/tests/empty_insert_tests.rs @@ -10,7 +10,6 @@ pub use crud::*; // use common::bakery_chain::*; use sea_orm::{DbConn, TryInsertResult}; - #[sea_orm_macros::test] #[cfg(any( feature = "sqlx-mysql", diff --git a/tests/loader_tests.rs b/tests/loader_tests.rs index e55a0666f..67341fdc6 100644 --- a/tests/loader_tests.rs +++ b/tests/loader_tests.rs @@ -1,7 +1,7 @@ pub mod common; pub use common::{bakery_chain::*, setup::*, TestContext}; -use sea_orm::{entity::*, DbConn, DbErr}; +use sea_orm::{entity::*, query::*, DbConn, DbErr, RuntimeErr}; #[sea_orm_macros::test] #[cfg(any( diff --git a/tests/pi_tests.rs b/tests/pi_tests.rs index 4362cd0b9..0d344ceee 100644 --- a/tests/pi_tests.rs +++ b/tests/pi_tests.rs @@ -1,6 +1,6 @@ pub mod common; -use common::{features::*}; +use common::{features::*, TestContext}; use pretty_assertions::assert_eq; use rust_decimal_macros::dec; use sea_orm::{entity::prelude::*, entity::*, DatabaseConnection}; diff --git a/tests/relational_tests.rs b/tests/relational_tests.rs index 0661c05ba..c8c41b17a 100644 --- a/tests/relational_tests.rs +++ b/tests/relational_tests.rs @@ -2,11 +2,11 @@ pub mod common; pub use chrono::offset::Utc; pub use common::{bakery_chain::*, setup::*, TestContext}; - +use pretty_assertions::assert_eq; pub use rust_decimal::prelude::*; pub use rust_decimal_macros::dec; - - +use sea_orm::{entity::*, query::*, DbErr, DerivePartialModel, FromQueryResult}; +use sea_query::{Expr, Func, SimpleExpr}; pub use uuid::Uuid; // Run the test locally: diff --git a/tests/returning_tests.rs b/tests/returning_tests.rs index 509bbb3c1..68abbf775 100644 --- a/tests/returning_tests.rs +++ b/tests/returning_tests.rs @@ -1,9 +1,9 @@ pub mod common; pub use common::{bakery_chain::*, setup::*, TestContext}; - +use sea_orm::{entity::prelude::*, IntoActiveModel}; pub use sea_query::{Expr, Query}; - +use serde_json::json; #[sea_orm_macros::test] #[cfg(any( @@ -79,7 +79,7 @@ async fn main() -> Result<(), DbErr> { should_panic(expected = "Database backend doesn't support RETURNING") )] async fn update_many() { - pub use common::{features::*, setup::*, TestContext}; + pub use common::{features::*, TestContext}; use edit_log::*; let run = || async { diff --git a/tests/time_crate_tests.rs b/tests/time_crate_tests.rs index 0f40de0a7..6a940330f 100644 --- a/tests/time_crate_tests.rs +++ b/tests/time_crate_tests.rs @@ -2,7 +2,7 @@ pub mod common; pub use common::{features::*, setup::*, TestContext}; use pretty_assertions::assert_eq; use sea_orm::{entity::prelude::*, DatabaseConnection, IntoActiveModel}; - +use serde_json::json; use time::macros::{date, time}; #[sea_orm_macros::test] @@ -40,7 +40,7 @@ pub async fn create_transaction_log(db: &DatabaseConnection) -> Result<(), DbErr Some(transaction_log.clone()) ); - let _json = TransactionLog::find().into_json().one(db).await?.unwrap(); + let json = TransactionLog::find().into_json().one(db).await?.unwrap(); #[cfg(feature = "sqlx-postgres")] assert_eq!( diff --git a/tests/transaction_tests.rs b/tests/transaction_tests.rs index dfcb95666..ffc937a6d 100644 --- a/tests/transaction_tests.rs +++ b/tests/transaction_tests.rs @@ -2,7 +2,7 @@ pub mod common; pub use common::{bakery_chain::*, setup::*, TestContext}; use pretty_assertions::assert_eq; -use sea_orm::{prelude::*, DatabaseTransaction, Set}; +use sea_orm::{prelude::*, AccessMode, DatabaseTransaction, IsolationLevel, Set, TransactionTrait}; #[sea_orm_macros::test] #[cfg(any( From 350fa86da8ed784613e929298a7e01df1edc6771 Mon Sep 17 00:00:00 2001 From: shogo-nakano-desu <61229807+shogo-nakano-desu@users.noreply.github.com> Date: Wed, 10 Jan 2024 20:58:36 +0900 Subject: [PATCH 04/20] chore: format --- .../duplicated_many_to_many_paths/bills.rs | 4 ++-- .../users_saved_bills.rs | 4 ++-- .../duplicated_many_to_many_paths/users_votes.rs | 4 ++-- .../src/tests_cfg/many_to_many/bills.rs | 4 ++-- .../src/tests_cfg/many_to_many/users_votes.rs | 4 ++-- .../src/tests_cfg/many_to_many_multiple/bills.rs | 4 ++-- .../many_to_many_multiple/users_votes.rs | 12 ++++++------ .../src/tests_cfg/self_referencing/bills.rs | 8 ++------ .../src/tests_cfg/self_referencing/users.rs | 16 ++++------------ tests/common/features/json_vec.rs | 6 +----- tests/common/setup/mod.rs | 2 +- 11 files changed, 26 insertions(+), 42 deletions(-) diff --git a/sea-orm-codegen/src/tests_cfg/duplicated_many_to_many_paths/bills.rs b/sea-orm-codegen/src/tests_cfg/duplicated_many_to_many_paths/bills.rs index a3a6911b9..baf33426e 100644 --- a/sea-orm-codegen/src/tests_cfg/duplicated_many_to_many_paths/bills.rs +++ b/sea-orm-codegen/src/tests_cfg/duplicated_many_to_many_paths/bills.rs @@ -5,7 +5,7 @@ use sea_orm::entity::prelude::*; pub struct Model { #[sea_orm(primary_key)] pub id: i32, - pub user_id: Option , + pub user_id: Option, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] @@ -15,7 +15,7 @@ pub enum Relation { from = "Column::UserId", to = "super::users::Column::Id", on_update = "NoAction", - on_delete = "NoAction", + on_delete = "NoAction" )] Users, #[sea_orm(has_many = "super::users_saved_bills::Entity")] diff --git a/sea-orm-codegen/src/tests_cfg/duplicated_many_to_many_paths/users_saved_bills.rs b/sea-orm-codegen/src/tests_cfg/duplicated_many_to_many_paths/users_saved_bills.rs index 4ef0281cd..575bac58f 100644 --- a/sea-orm-codegen/src/tests_cfg/duplicated_many_to_many_paths/users_saved_bills.rs +++ b/sea-orm-codegen/src/tests_cfg/duplicated_many_to_many_paths/users_saved_bills.rs @@ -16,7 +16,7 @@ pub enum Relation { from = "Column::BillId", to = "super::bills::Column::Id", on_update = "Cascade", - on_delete = "Cascade", + on_delete = "Cascade" )] Bills, #[sea_orm( @@ -24,7 +24,7 @@ pub enum Relation { from = "Column::UserId", to = "super::users::Column::Id", on_update = "Cascade", - on_delete = "Cascade", + on_delete = "Cascade" )] Users, } diff --git a/sea-orm-codegen/src/tests_cfg/duplicated_many_to_many_paths/users_votes.rs b/sea-orm-codegen/src/tests_cfg/duplicated_many_to_many_paths/users_votes.rs index a04ad7fa7..62f9cf7d0 100644 --- a/sea-orm-codegen/src/tests_cfg/duplicated_many_to_many_paths/users_votes.rs +++ b/sea-orm-codegen/src/tests_cfg/duplicated_many_to_many_paths/users_votes.rs @@ -17,7 +17,7 @@ pub enum Relation { from = "Column::BillId", to = "super::bills::Column::Id", on_update = "Cascade", - on_delete = "Cascade", + on_delete = "Cascade" )] Bills, #[sea_orm( @@ -25,7 +25,7 @@ pub enum Relation { from = "Column::UserId", to = "super::users::Column::Id", on_update = "Cascade", - on_delete = "Cascade", + on_delete = "Cascade" )] Users, } diff --git a/sea-orm-codegen/src/tests_cfg/many_to_many/bills.rs b/sea-orm-codegen/src/tests_cfg/many_to_many/bills.rs index 5a3acef9c..f2de469f0 100644 --- a/sea-orm-codegen/src/tests_cfg/many_to_many/bills.rs +++ b/sea-orm-codegen/src/tests_cfg/many_to_many/bills.rs @@ -5,7 +5,7 @@ use sea_orm::entity::prelude::*; pub struct Model { #[sea_orm(primary_key)] pub id: i32, - pub user_id: Option , + pub user_id: Option, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] @@ -15,7 +15,7 @@ pub enum Relation { from = "Column::UserId", to = "super::users::Column::Id", on_update = "NoAction", - on_delete = "NoAction", + on_delete = "NoAction" )] Users, #[sea_orm(has_many = "super::users_votes::Entity")] diff --git a/sea-orm-codegen/src/tests_cfg/many_to_many/users_votes.rs b/sea-orm-codegen/src/tests_cfg/many_to_many/users_votes.rs index a04ad7fa7..62f9cf7d0 100644 --- a/sea-orm-codegen/src/tests_cfg/many_to_many/users_votes.rs +++ b/sea-orm-codegen/src/tests_cfg/many_to_many/users_votes.rs @@ -17,7 +17,7 @@ pub enum Relation { from = "Column::BillId", to = "super::bills::Column::Id", on_update = "Cascade", - on_delete = "Cascade", + on_delete = "Cascade" )] Bills, #[sea_orm( @@ -25,7 +25,7 @@ pub enum Relation { from = "Column::UserId", to = "super::users::Column::Id", on_update = "Cascade", - on_delete = "Cascade", + on_delete = "Cascade" )] Users, } diff --git a/sea-orm-codegen/src/tests_cfg/many_to_many_multiple/bills.rs b/sea-orm-codegen/src/tests_cfg/many_to_many_multiple/bills.rs index 5094e5885..6874aeed0 100644 --- a/sea-orm-codegen/src/tests_cfg/many_to_many_multiple/bills.rs +++ b/sea-orm-codegen/src/tests_cfg/many_to_many_multiple/bills.rs @@ -5,7 +5,7 @@ use sea_orm::entity::prelude::*; pub struct Model { #[sea_orm(primary_key)] pub id: i32, - pub user_id: Option , + pub user_id: Option, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] @@ -15,7 +15,7 @@ pub enum Relation { from = "Column::UserId", to = "super::users::Column::Id", on_update = "NoAction", - on_delete = "NoAction", + on_delete = "NoAction" )] Users, } diff --git a/sea-orm-codegen/src/tests_cfg/many_to_many_multiple/users_votes.rs b/sea-orm-codegen/src/tests_cfg/many_to_many_multiple/users_votes.rs index 87187f4c0..29fb173cb 100644 --- a/sea-orm-codegen/src/tests_cfg/many_to_many_multiple/users_votes.rs +++ b/sea-orm-codegen/src/tests_cfg/many_to_many_multiple/users_votes.rs @@ -7,8 +7,8 @@ pub struct Model { pub user_id: i32, #[sea_orm(primary_key, auto_increment = false)] pub bill_id: i32, - pub user_idd: Option , - pub bill_idd: Option , + pub user_idd: Option, + pub bill_idd: Option, pub vote: bool, } @@ -17,25 +17,25 @@ pub enum Relation { #[sea_orm( belongs_to = "super::bills::Entity", from = "Column::BillIdd", - to = "super::bills::Column::Id", + to = "super::bills::Column::Id" )] Bills2, #[sea_orm( belongs_to = "super::bills::Entity", from = "Column::BillId", - to = "super::bills::Column::Id", + to = "super::bills::Column::Id" )] Bills1, #[sea_orm( belongs_to = "super::users::Entity", from = "Column::UserIdd", - to = "super::users::Column::Id", + to = "super::users::Column::Id" )] Users2, #[sea_orm( belongs_to = "super::users::Entity", from = "Column::UserId", - to = "super::users::Column::Id", + to = "super::users::Column::Id" )] Users1, } diff --git a/sea-orm-codegen/src/tests_cfg/self_referencing/bills.rs b/sea-orm-codegen/src/tests_cfg/self_referencing/bills.rs index 583655f67..22cfc4690 100644 --- a/sea-orm-codegen/src/tests_cfg/self_referencing/bills.rs +++ b/sea-orm-codegen/src/tests_cfg/self_referencing/bills.rs @@ -5,16 +5,12 @@ use sea_orm::entity::prelude::*; pub struct Model { #[sea_orm(primary_key)] pub id: i32, - pub self_id: Option , + pub self_id: Option, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] pub enum Relation { - #[sea_orm( - belongs_to = "Entity", - from = "Column::SelfId", - to = "Column::Id", - )] + #[sea_orm(belongs_to = "Entity", from = "Column::SelfId", to = "Column::Id")] SelfRef, } diff --git a/sea-orm-codegen/src/tests_cfg/self_referencing/users.rs b/sea-orm-codegen/src/tests_cfg/self_referencing/users.rs index b54f3e5e2..487ba9409 100644 --- a/sea-orm-codegen/src/tests_cfg/self_referencing/users.rs +++ b/sea-orm-codegen/src/tests_cfg/self_referencing/users.rs @@ -5,23 +5,15 @@ use sea_orm::entity::prelude::*; pub struct Model { #[sea_orm(primary_key)] pub id: i32, - pub self_id: Option , - pub self_idd: Option , + pub self_id: Option, + pub self_idd: Option, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] pub enum Relation { - #[sea_orm( - belongs_to = "Entity", - from = "Column::SelfId", - to = "Column::Id", - )] + #[sea_orm(belongs_to = "Entity", from = "Column::SelfId", to = "Column::Id")] SelfRef2, - #[sea_orm( - belongs_to = "Entity", - from = "Column::SelfIdd", - to = "Column::Id", - )] + #[sea_orm(belongs_to = "Entity", from = "Column::SelfIdd", to = "Column::Id")] SelfRef1, } diff --git a/tests/common/features/json_vec.rs b/tests/common/features/json_vec.rs index b86eaf20e..a1263b79e 100644 --- a/tests/common/features/json_vec.rs +++ b/tests/common/features/json_vec.rs @@ -22,11 +22,7 @@ impl TryGetableFromJson for StringVec {} impl From for Value { fn from(source: StringVec) -> Self { - sea_orm::Value::Json( - serde_json::to_value(source) - .ok() - .map(std::boxed::Box::new), - ) + sea_orm::Value::Json(serde_json::to_value(source).ok().map(std::boxed::Box::new)) } } diff --git a/tests/common/setup/mod.rs b/tests/common/setup/mod.rs index a1f91d79b..2385cfb0c 100644 --- a/tests/common/setup/mod.rs +++ b/tests/common/setup/mod.rs @@ -74,7 +74,7 @@ pub async fn tear_down(base_url: &str, db_name: &str) { format!("DROP DATABASE IF EXISTS \"{db_name}\";"), )) .await; - } ; + }; } pub async fn create_enum( From 9b80ac99344ee024f1fa6a659d550d125b35d07f Mon Sep 17 00:00:00 2001 From: shogo-nakano-desu <61229807+shogo-nakano-desu@users.noreply.github.com> Date: Wed, 10 Jan 2024 21:01:57 +0900 Subject: [PATCH 05/20] refactor: fix clippy --- src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 4026b5636..003288636 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -345,7 +345,6 @@ pub mod tests_cfg; mod util; pub use database::*; -pub use driver::*; pub use entity::*; pub use error::*; pub use executor::*; From 1620f33e71f31bd94884502c80ad231d6c02d14f Mon Sep 17 00:00:00 2001 From: shogo-nakano-desu <61229807+shogo-nakano-desu@users.noreply.github.com> Date: Wed, 10 Jan 2024 21:07:42 +0900 Subject: [PATCH 06/20] fix: import path --- src/database/db_connection.rs | 6 +++--- src/database/mock.rs | 7 ++++--- src/database/mod.rs | 4 ++-- src/database/stream/query.rs | 4 ++-- src/database/transaction.rs | 2 +- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/database/db_connection.rs b/src/database/db_connection.rs index 29815ec9f..30758efce 100644 --- a/src/database/db_connection.rs +++ b/src/database/db_connection.rs @@ -31,7 +31,7 @@ pub enum DatabaseConnection { /// Create a Mock database connection useful for testing #[cfg(feature = "mock")] - MockDatabaseConnection(Arc), + MockDatabaseConnection(Arc), /// Create a Proxy database connection useful for proxying #[cfg(feature = "proxy")] @@ -74,7 +74,7 @@ pub(crate) enum InnerConnection { #[cfg(feature = "sqlx-sqlite")] Sqlite(PoolConnection), #[cfg(feature = "mock")] - Mock(Arc), + Mock(Arc), #[cfg(feature = "proxy")] Proxy(Arc), } @@ -397,7 +397,7 @@ impl DatabaseConnection { /// # Panics /// /// Panics if [DbConn] is not a mock connection. - pub fn as_mock_connection(&self) -> &crate::MockDatabaseConnection { + pub fn as_mock_connection(&self) -> &crate::driver::MockDatabaseConnection { match self { DatabaseConnection::MockDatabaseConnection(mock_conn) => mock_conn, _ => panic!("Not mock connection"), diff --git a/src/database/mock.rs b/src/database/mock.rs index f038d8933..44bb46222 100644 --- a/src/database/mock.rs +++ b/src/database/mock.rs @@ -1,7 +1,8 @@ use crate::{ - error::*, DatabaseConnection, DbBackend, EntityTrait, ExecResult, ExecResultHolder, Iden, - IdenStatic, Iterable, MockDatabaseConnection, MockDatabaseTrait, ModelTrait, QueryResult, - QueryResultRow, SelectA, SelectB, Statement, + driver::{MockDatabaseConnection, MockDatabaseTrait}, + error::*, + DatabaseConnection, DbBackend, EntityTrait, ExecResult, ExecResultHolder, Iden, IdenStatic, + Iterable, ModelTrait, QueryResult, QueryResultRow, SelectA, SelectB, Statement, }; use sea_query::{Value, ValueType, Values}; use std::{collections::BTreeMap, sync::Arc}; diff --git a/src/database/mod.rs b/src/database/mod.rs index a844d1c85..e85431d2b 100644 --- a/src/database/mod.rs +++ b/src/database/mod.rs @@ -82,8 +82,8 @@ impl Database { return crate::SqlxSqliteConnector::connect(opt).await; } #[cfg(feature = "mock")] - if crate::MockDatabaseConnector::accepts(&opt.url) { - return crate::MockDatabaseConnector::connect(&opt.url).await; + if crate::driver::MockDatabaseConnector::accepts(&opt.url) { + return crate::driver::MockDatabaseConnector::connect(&opt.url).await; } Err(conn_err(format!( diff --git a/src/database/stream/query.rs b/src/database/stream/query.rs index 30642bde0..78e97e6ff 100644 --- a/src/database/stream/query.rs +++ b/src/database/stream/query.rs @@ -89,14 +89,14 @@ impl #[cfg(feature = "mock")] impl From<( - Arc, + Arc, Statement, Option, )> for QueryStream { fn from( (conn, stmt, metric_callback): ( - Arc, + Arc, Statement, Option, ), diff --git a/src/database/transaction.rs b/src/database/transaction.rs index 3216ffd99..ace344975 100644 --- a/src/database/transaction.rs +++ b/src/database/transaction.rs @@ -81,7 +81,7 @@ impl DatabaseTransaction { #[cfg(feature = "mock")] pub(crate) async fn new_mock( - inner: Arc, + inner: Arc, metric_callback: Option, ) -> Result { let backend = inner.get_database_backend(); From 86d6170cee54a70ba30cf2c1f57075e16be66162 Mon Sep 17 00:00:00 2001 From: shogo-nakano-desu <61229807+shogo-nakano-desu@users.noreply.github.com> Date: Wed, 10 Jan 2024 21:18:57 +0900 Subject: [PATCH 07/20] refactor: fix clippy errors and wornings of sqlx-sqlite, sqlx-mysql, sqlx-postgres --- src/database/db_connection.rs | 10 +++++----- src/database/mod.rs | 12 ++++++------ src/database/transaction.rs | 4 ++-- src/driver/mock.rs | 6 +++--- src/driver/sqlx_mysql.rs | 10 ---------- src/driver/sqlx_postgres.rs | 10 ---------- src/driver/sqlx_sqlite.rs | 10 ---------- 7 files changed, 16 insertions(+), 46 deletions(-) diff --git a/src/database/db_connection.rs b/src/database/db_connection.rs index 30758efce..3746fb948 100644 --- a/src/database/db_connection.rs +++ b/src/database/db_connection.rs @@ -19,15 +19,15 @@ use std::sync::Arc; pub enum DatabaseConnection { /// Create a MYSQL database connection and pool #[cfg(feature = "sqlx-mysql")] - SqlxMySqlPoolConnection(crate::SqlxMySqlPoolConnection), + SqlxMySqlPoolConnection(crate::driver::SqlxMySqlPoolConnection), /// Create a PostgreSQL database connection and pool #[cfg(feature = "sqlx-postgres")] - SqlxPostgresPoolConnection(crate::SqlxPostgresPoolConnection), + SqlxPostgresPoolConnection(crate::driver::SqlxPostgresPoolConnection), /// Create a SQLite database connection and pool #[cfg(feature = "sqlx-sqlite")] - SqlxSqlitePoolConnection(crate::SqlxSqlitePoolConnection), + SqlxSqlitePoolConnection(crate::driver::SqlxSqlitePoolConnection), /// Create a Mock database connection useful for testing #[cfg(feature = "mock")] @@ -35,7 +35,7 @@ pub enum DatabaseConnection { /// Create a Proxy database connection useful for proxying #[cfg(feature = "proxy")] - ProxyDatabaseConnection(Arc), + ProxyDatabaseConnection(Arc), /// The connection to the database has been severed Disconnected, @@ -76,7 +76,7 @@ pub(crate) enum InnerConnection { #[cfg(feature = "mock")] Mock(Arc), #[cfg(feature = "proxy")] - Proxy(Arc), + Proxy(Arc), } impl std::fmt::Debug for DatabaseConnection { diff --git a/src/database/mod.rs b/src/database/mod.rs index e85431d2b..aa6541d4e 100644 --- a/src/database/mod.rs +++ b/src/database/mod.rs @@ -71,15 +71,15 @@ impl Database { #[cfg(feature = "sqlx-mysql")] if DbBackend::MySql.is_prefix_of(&opt.url) { - return crate::SqlxMySqlConnector::connect(opt).await; + return crate::driver::SqlxMySqlConnector::connect(opt).await; } #[cfg(feature = "sqlx-postgres")] if DbBackend::Postgres.is_prefix_of(&opt.url) { - return crate::SqlxPostgresConnector::connect(opt).await; + return crate::driver::SqlxPostgresConnector::connect(opt).await; } #[cfg(feature = "sqlx-sqlite")] if DbBackend::Sqlite.is_prefix_of(&opt.url) { - return crate::SqlxSqliteConnector::connect(opt).await; + return crate::driver::SqlxSqliteConnector::connect(opt).await; } #[cfg(feature = "mock")] if crate::driver::MockDatabaseConnector::accepts(&opt.url) { @@ -101,19 +101,19 @@ impl Database { ) -> Result { match db_type { DbBackend::MySql => { - return crate::ProxyDatabaseConnector::connect( + return crate::driver::ProxyDatabaseConnector::connect( DbBackend::MySql, proxy_func_arc.to_owned(), ); } DbBackend::Postgres => { - return crate::ProxyDatabaseConnector::connect( + return crate::driver::ProxyDatabaseConnector::connect( DbBackend::Postgres, proxy_func_arc.to_owned(), ); } DbBackend::Sqlite => { - return crate::ProxyDatabaseConnector::connect( + return crate::driver::ProxyDatabaseConnector::connect( DbBackend::Sqlite, proxy_func_arc.to_owned(), ); diff --git a/src/database/transaction.rs b/src/database/transaction.rs index ace344975..f4b9eacb4 100644 --- a/src/database/transaction.rs +++ b/src/database/transaction.rs @@ -1,10 +1,10 @@ +#[cfg(feature = "sqlx-dep")] +use crate::driver::{sqlx_error_to_exec_err, sqlx_error_to_query_err}; use crate::{ debug_print, error::*, AccessMode, ConnectionTrait, DbBackend, DbErr, ExecResult, InnerConnection, IsolationLevel, QueryResult, Statement, StreamTrait, TransactionStream, TransactionTrait, }; -#[cfg(feature = "sqlx-dep")] -use crate::{sqlx_error_to_exec_err, sqlx_error_to_query_err}; use futures::lock::Mutex; #[cfg(feature = "sqlx-dep")] use sqlx::{pool::PoolConnection, TransactionManager}; diff --git a/src/driver/mock.rs b/src/driver/mock.rs index 716173b38..70d34ba3d 100644 --- a/src/driver/mock.rs +++ b/src/driver/mock.rs @@ -84,15 +84,15 @@ impl MockDatabaseConnector { } #[cfg(feature = "sqlx-mysql")] - if crate::SqlxMySqlConnector::accepts(string) { + if crate::driver::SqlxMySqlConnector::accepts(string) { return connect_mock_db!(DbBackend::MySql); } #[cfg(feature = "sqlx-postgres")] - if crate::SqlxPostgresConnector::accepts(string) { + if crate::driver::SqlxPostgresConnector::accepts(string) { return connect_mock_db!(DbBackend::Postgres); } #[cfg(feature = "sqlx-sqlite")] - if crate::SqlxSqliteConnector::accepts(string) { + if crate::driver::SqlxSqliteConnector::accepts(string) { return connect_mock_db!(DbBackend::Sqlite); } connect_mock_db!(DbBackend::Postgres) diff --git a/src/driver/sqlx_mysql.rs b/src/driver/sqlx_mysql.rs index 51a1842a7..42ed652d9 100644 --- a/src/driver/sqlx_mysql.rs +++ b/src/driver/sqlx_mysql.rs @@ -65,16 +65,6 @@ impl SqlxMySqlConnector { } } -impl SqlxMySqlConnector { - /// Instantiate a sqlx pool connection to a [DatabaseConnection] - pub fn from_sqlx_mysql_pool(pool: MySqlPool) -> DatabaseConnection { - DatabaseConnection::SqlxMySqlPoolConnection(SqlxMySqlPoolConnection { - pool, - metric_callback: None, - }) - } -} - impl SqlxMySqlPoolConnection { /// Execute a [Statement] on a MySQL backend #[instrument(level = "trace")] diff --git a/src/driver/sqlx_postgres.rs b/src/driver/sqlx_postgres.rs index 1214f6c29..16d328ea1 100644 --- a/src/driver/sqlx_postgres.rs +++ b/src/driver/sqlx_postgres.rs @@ -80,16 +80,6 @@ impl SqlxPostgresConnector { } } -impl SqlxPostgresConnector { - /// Instantiate a sqlx pool connection to a [DatabaseConnection] - pub fn from_sqlx_postgres_pool(pool: PgPool) -> DatabaseConnection { - DatabaseConnection::SqlxPostgresPoolConnection(SqlxPostgresPoolConnection { - pool, - metric_callback: None, - }) - } -} - impl SqlxPostgresPoolConnection { /// Execute a [Statement] on a PostgreSQL backend #[instrument(level = "trace")] diff --git a/src/driver/sqlx_sqlite.rs b/src/driver/sqlx_sqlite.rs index 8a9924cf5..9674a1c32 100644 --- a/src/driver/sqlx_sqlite.rs +++ b/src/driver/sqlx_sqlite.rs @@ -72,16 +72,6 @@ impl SqlxSqliteConnector { } } -impl SqlxSqliteConnector { - /// Instantiate a sqlx pool connection to a [DatabaseConnection] - pub fn from_sqlx_sqlite_pool(pool: SqlitePool) -> DatabaseConnection { - DatabaseConnection::SqlxSqlitePoolConnection(SqlxSqlitePoolConnection { - pool, - metric_callback: None, - }) - } -} - impl SqlxSqlitePoolConnection { /// Execute a [Statement] on a SQLite backend #[instrument(level = "trace")] From fc48065232945cd2027eeedfcb8de3201f100539 Mon Sep 17 00:00:00 2001 From: shogo-nakano-desu <61229807+shogo-nakano-desu@users.noreply.github.com> Date: Wed, 10 Jan 2024 21:25:24 +0900 Subject: [PATCH 08/20] fix: revert some space and comma removal --- .../tests_cfg/duplicated_many_to_many_paths/bills.rs | 4 ++-- .../users_saved_bills.rs | 4 ++-- .../duplicated_many_to_many_paths/users_votes.rs | 4 ++-- sea-orm-codegen/src/tests_cfg/many_to_many/bills.rs | 4 ++-- .../src/tests_cfg/many_to_many/users_votes.rs | 4 ++-- .../src/tests_cfg/many_to_many_multiple/bills.rs | 4 ++-- .../tests_cfg/many_to_many_multiple/users_votes.rs | 12 ++++++------ .../src/tests_cfg/self_referencing/bills.rs | 2 +- .../src/tests_cfg/self_referencing/users.rs | 4 ++-- 9 files changed, 21 insertions(+), 21 deletions(-) diff --git a/sea-orm-codegen/src/tests_cfg/duplicated_many_to_many_paths/bills.rs b/sea-orm-codegen/src/tests_cfg/duplicated_many_to_many_paths/bills.rs index baf33426e..a3a6911b9 100644 --- a/sea-orm-codegen/src/tests_cfg/duplicated_many_to_many_paths/bills.rs +++ b/sea-orm-codegen/src/tests_cfg/duplicated_many_to_many_paths/bills.rs @@ -5,7 +5,7 @@ use sea_orm::entity::prelude::*; pub struct Model { #[sea_orm(primary_key)] pub id: i32, - pub user_id: Option, + pub user_id: Option , } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] @@ -15,7 +15,7 @@ pub enum Relation { from = "Column::UserId", to = "super::users::Column::Id", on_update = "NoAction", - on_delete = "NoAction" + on_delete = "NoAction", )] Users, #[sea_orm(has_many = "super::users_saved_bills::Entity")] diff --git a/sea-orm-codegen/src/tests_cfg/duplicated_many_to_many_paths/users_saved_bills.rs b/sea-orm-codegen/src/tests_cfg/duplicated_many_to_many_paths/users_saved_bills.rs index 575bac58f..4ef0281cd 100644 --- a/sea-orm-codegen/src/tests_cfg/duplicated_many_to_many_paths/users_saved_bills.rs +++ b/sea-orm-codegen/src/tests_cfg/duplicated_many_to_many_paths/users_saved_bills.rs @@ -16,7 +16,7 @@ pub enum Relation { from = "Column::BillId", to = "super::bills::Column::Id", on_update = "Cascade", - on_delete = "Cascade" + on_delete = "Cascade", )] Bills, #[sea_orm( @@ -24,7 +24,7 @@ pub enum Relation { from = "Column::UserId", to = "super::users::Column::Id", on_update = "Cascade", - on_delete = "Cascade" + on_delete = "Cascade", )] Users, } diff --git a/sea-orm-codegen/src/tests_cfg/duplicated_many_to_many_paths/users_votes.rs b/sea-orm-codegen/src/tests_cfg/duplicated_many_to_many_paths/users_votes.rs index 62f9cf7d0..a04ad7fa7 100644 --- a/sea-orm-codegen/src/tests_cfg/duplicated_many_to_many_paths/users_votes.rs +++ b/sea-orm-codegen/src/tests_cfg/duplicated_many_to_many_paths/users_votes.rs @@ -17,7 +17,7 @@ pub enum Relation { from = "Column::BillId", to = "super::bills::Column::Id", on_update = "Cascade", - on_delete = "Cascade" + on_delete = "Cascade", )] Bills, #[sea_orm( @@ -25,7 +25,7 @@ pub enum Relation { from = "Column::UserId", to = "super::users::Column::Id", on_update = "Cascade", - on_delete = "Cascade" + on_delete = "Cascade", )] Users, } diff --git a/sea-orm-codegen/src/tests_cfg/many_to_many/bills.rs b/sea-orm-codegen/src/tests_cfg/many_to_many/bills.rs index f2de469f0..5a3acef9c 100644 --- a/sea-orm-codegen/src/tests_cfg/many_to_many/bills.rs +++ b/sea-orm-codegen/src/tests_cfg/many_to_many/bills.rs @@ -5,7 +5,7 @@ use sea_orm::entity::prelude::*; pub struct Model { #[sea_orm(primary_key)] pub id: i32, - pub user_id: Option, + pub user_id: Option , } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] @@ -15,7 +15,7 @@ pub enum Relation { from = "Column::UserId", to = "super::users::Column::Id", on_update = "NoAction", - on_delete = "NoAction" + on_delete = "NoAction", )] Users, #[sea_orm(has_many = "super::users_votes::Entity")] diff --git a/sea-orm-codegen/src/tests_cfg/many_to_many/users_votes.rs b/sea-orm-codegen/src/tests_cfg/many_to_many/users_votes.rs index 62f9cf7d0..a04ad7fa7 100644 --- a/sea-orm-codegen/src/tests_cfg/many_to_many/users_votes.rs +++ b/sea-orm-codegen/src/tests_cfg/many_to_many/users_votes.rs @@ -17,7 +17,7 @@ pub enum Relation { from = "Column::BillId", to = "super::bills::Column::Id", on_update = "Cascade", - on_delete = "Cascade" + on_delete = "Cascade", )] Bills, #[sea_orm( @@ -25,7 +25,7 @@ pub enum Relation { from = "Column::UserId", to = "super::users::Column::Id", on_update = "Cascade", - on_delete = "Cascade" + on_delete = "Cascade", )] Users, } diff --git a/sea-orm-codegen/src/tests_cfg/many_to_many_multiple/bills.rs b/sea-orm-codegen/src/tests_cfg/many_to_many_multiple/bills.rs index 6874aeed0..5094e5885 100644 --- a/sea-orm-codegen/src/tests_cfg/many_to_many_multiple/bills.rs +++ b/sea-orm-codegen/src/tests_cfg/many_to_many_multiple/bills.rs @@ -5,7 +5,7 @@ use sea_orm::entity::prelude::*; pub struct Model { #[sea_orm(primary_key)] pub id: i32, - pub user_id: Option, + pub user_id: Option , } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] @@ -15,7 +15,7 @@ pub enum Relation { from = "Column::UserId", to = "super::users::Column::Id", on_update = "NoAction", - on_delete = "NoAction" + on_delete = "NoAction", )] Users, } diff --git a/sea-orm-codegen/src/tests_cfg/many_to_many_multiple/users_votes.rs b/sea-orm-codegen/src/tests_cfg/many_to_many_multiple/users_votes.rs index 29fb173cb..87187f4c0 100644 --- a/sea-orm-codegen/src/tests_cfg/many_to_many_multiple/users_votes.rs +++ b/sea-orm-codegen/src/tests_cfg/many_to_many_multiple/users_votes.rs @@ -7,8 +7,8 @@ pub struct Model { pub user_id: i32, #[sea_orm(primary_key, auto_increment = false)] pub bill_id: i32, - pub user_idd: Option, - pub bill_idd: Option, + pub user_idd: Option , + pub bill_idd: Option , pub vote: bool, } @@ -17,25 +17,25 @@ pub enum Relation { #[sea_orm( belongs_to = "super::bills::Entity", from = "Column::BillIdd", - to = "super::bills::Column::Id" + to = "super::bills::Column::Id", )] Bills2, #[sea_orm( belongs_to = "super::bills::Entity", from = "Column::BillId", - to = "super::bills::Column::Id" + to = "super::bills::Column::Id", )] Bills1, #[sea_orm( belongs_to = "super::users::Entity", from = "Column::UserIdd", - to = "super::users::Column::Id" + to = "super::users::Column::Id", )] Users2, #[sea_orm( belongs_to = "super::users::Entity", from = "Column::UserId", - to = "super::users::Column::Id" + to = "super::users::Column::Id", )] Users1, } diff --git a/sea-orm-codegen/src/tests_cfg/self_referencing/bills.rs b/sea-orm-codegen/src/tests_cfg/self_referencing/bills.rs index 22cfc4690..e906cdc18 100644 --- a/sea-orm-codegen/src/tests_cfg/self_referencing/bills.rs +++ b/sea-orm-codegen/src/tests_cfg/self_referencing/bills.rs @@ -5,7 +5,7 @@ use sea_orm::entity::prelude::*; pub struct Model { #[sea_orm(primary_key)] pub id: i32, - pub self_id: Option, + pub self_id: Option , } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] diff --git a/sea-orm-codegen/src/tests_cfg/self_referencing/users.rs b/sea-orm-codegen/src/tests_cfg/self_referencing/users.rs index 487ba9409..6ebfbb045 100644 --- a/sea-orm-codegen/src/tests_cfg/self_referencing/users.rs +++ b/sea-orm-codegen/src/tests_cfg/self_referencing/users.rs @@ -5,8 +5,8 @@ use sea_orm::entity::prelude::*; pub struct Model { #[sea_orm(primary_key)] pub id: i32, - pub self_id: Option, - pub self_idd: Option, + pub self_id: Option , + pub self_idd: Option , } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] From ae017dc663154771531e4dd942bc813fc25bd6d6 Mon Sep 17 00:00:00 2001 From: shogo-nakano-desu <61229807+shogo-nakano-desu@users.noreply.github.com> Date: Wed, 10 Jan 2024 21:27:10 +0900 Subject: [PATCH 09/20] fix: revert some space and comma removal --- .../src/tests_cfg/self_referencing/bills.rs | 6 +++++- .../src/tests_cfg/self_referencing/users.rs | 12 ++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/sea-orm-codegen/src/tests_cfg/self_referencing/bills.rs b/sea-orm-codegen/src/tests_cfg/self_referencing/bills.rs index e906cdc18..583655f67 100644 --- a/sea-orm-codegen/src/tests_cfg/self_referencing/bills.rs +++ b/sea-orm-codegen/src/tests_cfg/self_referencing/bills.rs @@ -10,7 +10,11 @@ pub struct Model { #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] pub enum Relation { - #[sea_orm(belongs_to = "Entity", from = "Column::SelfId", to = "Column::Id")] + #[sea_orm( + belongs_to = "Entity", + from = "Column::SelfId", + to = "Column::Id", + )] SelfRef, } diff --git a/sea-orm-codegen/src/tests_cfg/self_referencing/users.rs b/sea-orm-codegen/src/tests_cfg/self_referencing/users.rs index 6ebfbb045..b54f3e5e2 100644 --- a/sea-orm-codegen/src/tests_cfg/self_referencing/users.rs +++ b/sea-orm-codegen/src/tests_cfg/self_referencing/users.rs @@ -11,9 +11,17 @@ pub struct Model { #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] pub enum Relation { - #[sea_orm(belongs_to = "Entity", from = "Column::SelfId", to = "Column::Id")] + #[sea_orm( + belongs_to = "Entity", + from = "Column::SelfId", + to = "Column::Id", + )] SelfRef2, - #[sea_orm(belongs_to = "Entity", from = "Column::SelfIdd", to = "Column::Id")] + #[sea_orm( + belongs_to = "Entity", + from = "Column::SelfIdd", + to = "Column::Id", + )] SelfRef1, } From b93c911db99f165aadd20b0453725f3f90d58529 Mon Sep 17 00:00:00 2001 From: shogo-nakano-desu <61229807+shogo-nakano-desu@users.noreply.github.com> Date: Wed, 10 Jan 2024 21:35:52 +0900 Subject: [PATCH 10/20] refactor: add feature flag --- src/driver/sqlx_mysql.rs | 1 + src/driver/sqlx_postgres.rs | 1 + src/driver/sqlx_sqlite.rs | 1 + tests/self_join_tests.rs | 2 ++ 4 files changed, 5 insertions(+) diff --git a/src/driver/sqlx_mysql.rs b/src/driver/sqlx_mysql.rs index 42ed652d9..8707eaa25 100644 --- a/src/driver/sqlx_mysql.rs +++ b/src/driver/sqlx_mysql.rs @@ -36,6 +36,7 @@ impl std::fmt::Debug for SqlxMySqlPoolConnection { impl SqlxMySqlConnector { /// Check if the URI provided corresponds to `mysql://` for a MySQL database + #[cfg(feature = "mock")] pub fn accepts(string: &str) -> bool { string.starts_with("mysql://") && string.parse::().is_ok() } diff --git a/src/driver/sqlx_postgres.rs b/src/driver/sqlx_postgres.rs index 16d328ea1..be404b658 100644 --- a/src/driver/sqlx_postgres.rs +++ b/src/driver/sqlx_postgres.rs @@ -36,6 +36,7 @@ impl std::fmt::Debug for SqlxPostgresPoolConnection { impl SqlxPostgresConnector { /// Check if the URI provided corresponds to `postgres://` for a PostgreSQL database + #[cfg(feature = "mock")] pub fn accepts(string: &str) -> bool { string.starts_with("postgres://") && string.parse::().is_ok() } diff --git a/src/driver/sqlx_sqlite.rs b/src/driver/sqlx_sqlite.rs index 9674a1c32..5fa02dd11 100644 --- a/src/driver/sqlx_sqlite.rs +++ b/src/driver/sqlx_sqlite.rs @@ -36,6 +36,7 @@ impl std::fmt::Debug for SqlxSqlitePoolConnection { impl SqlxSqliteConnector { /// Check if the URI provided corresponds to `sqlite:` for a SQLite database + #[cfg(feature = "mock")] pub fn accepts(string: &str) -> bool { string.starts_with("sqlite:") && string.parse::().is_ok() } diff --git a/tests/self_join_tests.rs b/tests/self_join_tests.rs index f35dd5050..df33299ae 100644 --- a/tests/self_join_tests.rs +++ b/tests/self_join_tests.rs @@ -90,6 +90,7 @@ pub async fn create_metadata(db: &DatabaseConnection) -> Result<(), DbErr> { Ok(()) } +#[cfg(feature = "test")] fn find_linked_001() { use self_join::*; @@ -114,6 +115,7 @@ fn find_linked_001() { ); } +#[cfg(feature = "test")] fn find_also_linked_001() { use self_join::*; From 98b6f24edccbe7f84ac59b900d199253eb1e2f58 Mon Sep 17 00:00:00 2001 From: shogo-nakano-desu <61229807+shogo-nakano-desu@users.noreply.github.com> Date: Wed, 10 Jan 2024 21:39:55 +0900 Subject: [PATCH 11/20] fix: import path --- src/database/db_connection.rs | 2 +- src/database/stream/query.rs | 4 ++-- src/database/transaction.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/database/db_connection.rs b/src/database/db_connection.rs index 3746fb948..d7f3fbce2 100644 --- a/src/database/db_connection.rs +++ b/src/database/db_connection.rs @@ -426,7 +426,7 @@ impl DatabaseConnection { /// # Panics /// /// Panics if [DbConn] is not a proxy connection. - pub fn as_proxy_connection(&self) -> &crate::ProxyDatabaseConnection { + pub fn as_proxy_connection(&self) -> &crate::driver::ProxyDatabaseConnection { match self { DatabaseConnection::ProxyDatabaseConnection(proxy_conn) => proxy_conn, _ => panic!("Not proxy connection"), diff --git a/src/database/stream/query.rs b/src/database/stream/query.rs index 78e97e6ff..8af12d3e4 100644 --- a/src/database/stream/query.rs +++ b/src/database/stream/query.rs @@ -108,14 +108,14 @@ impl #[cfg(feature = "proxy")] impl From<( - Arc, + Arc, Statement, Option, )> for QueryStream { fn from( (conn, stmt, metric_callback): ( - Arc, + Arc, Statement, Option, ), diff --git a/src/database/transaction.rs b/src/database/transaction.rs index f4b9eacb4..15d157201 100644 --- a/src/database/transaction.rs +++ b/src/database/transaction.rs @@ -97,7 +97,7 @@ impl DatabaseTransaction { #[cfg(feature = "proxy")] pub(crate) async fn new_proxy( - inner: Arc, + inner: Arc, metric_callback: Option, ) -> Result { let backend = inner.get_database_backend(); From 1b3cc3e996510627108e7d58b77f6acd93cde701 Mon Sep 17 00:00:00 2001 From: shogo-nakano-desu <61229807+shogo-nakano-desu@users.noreply.github.com> Date: Wed, 10 Jan 2024 21:42:58 +0900 Subject: [PATCH 12/20] test: remove mismatch feature flag --- tests/self_join_tests.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/self_join_tests.rs b/tests/self_join_tests.rs index df33299ae..8ce6eac28 100644 --- a/tests/self_join_tests.rs +++ b/tests/self_join_tests.rs @@ -115,7 +115,6 @@ fn find_linked_001() { ); } -#[cfg(feature = "test")] fn find_also_linked_001() { use self_join::*; From b04fdf8699a2c5aa022b24e4240f86c2c8e31760 Mon Sep 17 00:00:00 2001 From: shogo-nakano-desu <61229807+shogo-nakano-desu@users.noreply.github.com> Date: Wed, 10 Jan 2024 21:44:07 +0900 Subject: [PATCH 13/20] test: remove mismatch feature flag --- tests/self_join_tests.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/self_join_tests.rs b/tests/self_join_tests.rs index 8ce6eac28..f35dd5050 100644 --- a/tests/self_join_tests.rs +++ b/tests/self_join_tests.rs @@ -90,7 +90,6 @@ pub async fn create_metadata(db: &DatabaseConnection) -> Result<(), DbErr> { Ok(()) } -#[cfg(feature = "test")] fn find_linked_001() { use self_join::*; From 6dc67485d00cad0e74cbc0bd97702ba29003b394 Mon Sep 17 00:00:00 2001 From: shogo-nakano-desu <61229807+shogo-nakano-desu@users.noreply.github.com> Date: Wed, 10 Jan 2024 21:45:06 +0900 Subject: [PATCH 14/20] chore: add proper feature flag --- tests/self_join_tests.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/self_join_tests.rs b/tests/self_join_tests.rs index f35dd5050..6e0af739c 100644 --- a/tests/self_join_tests.rs +++ b/tests/self_join_tests.rs @@ -90,6 +90,12 @@ pub async fn create_metadata(db: &DatabaseConnection) -> Result<(), DbErr> { Ok(()) } +#[sea_orm_macros::test] +#[cfg(any( + feature = "sqlx-mysql", + feature = "sqlx-sqlite", + feature = "sqlx-postgres" +))] fn find_linked_001() { use self_join::*; @@ -114,6 +120,12 @@ fn find_linked_001() { ); } +#[sea_orm_macros::test] +#[cfg(any( + feature = "sqlx-mysql", + feature = "sqlx-sqlite", + feature = "sqlx-postgres" +))] fn find_also_linked_001() { use self_join::*; From 8916c284aa396cbd2146c11c6ef2028a8006843d Mon Sep 17 00:00:00 2001 From: shogo-nakano-desu <61229807+shogo-nakano-desu@users.noreply.github.com> Date: Wed, 10 Jan 2024 22:01:30 +0900 Subject: [PATCH 15/20] chore: remove feature flag --- tests/self_join_tests.rs | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/tests/self_join_tests.rs b/tests/self_join_tests.rs index 6e0af739c..f35dd5050 100644 --- a/tests/self_join_tests.rs +++ b/tests/self_join_tests.rs @@ -90,12 +90,6 @@ pub async fn create_metadata(db: &DatabaseConnection) -> Result<(), DbErr> { Ok(()) } -#[sea_orm_macros::test] -#[cfg(any( - feature = "sqlx-mysql", - feature = "sqlx-sqlite", - feature = "sqlx-postgres" -))] fn find_linked_001() { use self_join::*; @@ -120,12 +114,6 @@ fn find_linked_001() { ); } -#[sea_orm_macros::test] -#[cfg(any( - feature = "sqlx-mysql", - feature = "sqlx-sqlite", - feature = "sqlx-postgres" -))] fn find_also_linked_001() { use self_join::*; From 889d250d54663f0b35fcdb3c1981ba1b820a252c Mon Sep 17 00:00:00 2001 From: shogo-nakano-desu <61229807+shogo-nakano-desu@users.noreply.github.com> Date: Wed, 10 Jan 2024 23:59:40 +0900 Subject: [PATCH 16/20] refactor: remove clippy.toml file --- clippy.toml | 1 - src/database/mock.rs | 1 + src/entity/active_model.rs | 1 + src/query/json.rs | 1 + 4 files changed, 3 insertions(+), 1 deletion(-) delete mode 100644 clippy.toml diff --git a/clippy.toml b/clippy.toml deleted file mode 100644 index 154626ef4..000000000 --- a/clippy.toml +++ /dev/null @@ -1 +0,0 @@ -allow-unwrap-in-tests = true diff --git a/src/database/mock.rs b/src/database/mock.rs index 44bb46222..de11c7ea1 100644 --- a/src/database/mock.rs +++ b/src/database/mock.rs @@ -1,3 +1,4 @@ +#![allow(clippy::unwrap_used, clippy::expect_used)] use crate::{ driver::{MockDatabaseConnection, MockDatabaseTrait}, error::*, diff --git a/src/entity/active_model.rs b/src/entity/active_model.rs index c0e344840..7ec8cb205 100644 --- a/src/entity/active_model.rs +++ b/src/entity/active_model.rs @@ -1,3 +1,4 @@ +#![allow(clippy::unwrap_used, clippy::expect_used)] use crate::{ error::*, ConnectionTrait, DeleteResult, EntityTrait, Iterable, PrimaryKeyToColumn, Value, }; diff --git a/src/query/json.rs b/src/query/json.rs index da91fb3b6..901ce358d 100644 --- a/src/query/json.rs +++ b/src/query/json.rs @@ -1,3 +1,4 @@ +#![allow(clippy::unwrap_used, clippy::expect_used)] use crate::{error::*, FromQueryResult, QueryResult}; use serde_json::Map; pub use serde_json::Value as JsonValue; From 138b9dc75a006e5fcf2809455ff3aea534662d03 Mon Sep 17 00:00:00 2001 From: shogo-nakano-desu <61229807+shogo-nakano-desu@users.noreply.github.com> Date: Thu, 11 Jan 2024 00:01:44 +0900 Subject: [PATCH 17/20] fix: re-export driver --- src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib.rs b/src/lib.rs index 003288636..4026b5636 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -345,6 +345,7 @@ pub mod tests_cfg; mod util; pub use database::*; +pub use driver::*; pub use entity::*; pub use error::*; pub use executor::*; From e4f4a129b9a1220ddc41fc5de2dff9866aaf9388 Mon Sep 17 00:00:00 2001 From: shogo-nakano-desu <61229807+shogo-nakano-desu@users.noreply.github.com> Date: Thu, 11 Jan 2024 00:02:19 +0900 Subject: [PATCH 18/20] fix: re-export JoinType --- src/query/combine.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/query/combine.rs b/src/query/combine.rs index 0f2d0290c..621690961 100644 --- a/src/query/combine.rs +++ b/src/query/combine.rs @@ -2,6 +2,8 @@ use crate::{ ColumnTrait, EntityTrait, IdenStatic, Iterable, QueryTrait, Select, SelectTwo, SelectTwoMany, }; use core::marker::PhantomData; +#[allow(unused_imports)] +pub use sea_query::JoinType; use sea_query::{Alias, ColumnRef, Iden, Order, SeaRc, SelectExpr, SelectStatement, SimpleExpr}; macro_rules! select_def { From 09f845ad52fc6637ec25f66633ed6f04b6bb2153 Mon Sep 17 00:00:00 2001 From: shogo-nakano-desu <61229807+shogo-nakano-desu@users.noreply.github.com> Date: Thu, 11 Jan 2024 00:02:40 +0900 Subject: [PATCH 19/20] fix: remove feature flag --- src/driver/sqlx_mysql.rs | 2 +- src/driver/sqlx_postgres.rs | 2 +- src/driver/sqlx_sqlite.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/driver/sqlx_mysql.rs b/src/driver/sqlx_mysql.rs index 8707eaa25..01d615886 100644 --- a/src/driver/sqlx_mysql.rs +++ b/src/driver/sqlx_mysql.rs @@ -36,7 +36,7 @@ impl std::fmt::Debug for SqlxMySqlPoolConnection { impl SqlxMySqlConnector { /// Check if the URI provided corresponds to `mysql://` for a MySQL database - #[cfg(feature = "mock")] + #[allow(unused_variables)] pub fn accepts(string: &str) -> bool { string.starts_with("mysql://") && string.parse::().is_ok() } diff --git a/src/driver/sqlx_postgres.rs b/src/driver/sqlx_postgres.rs index be404b658..656692701 100644 --- a/src/driver/sqlx_postgres.rs +++ b/src/driver/sqlx_postgres.rs @@ -36,7 +36,7 @@ impl std::fmt::Debug for SqlxPostgresPoolConnection { impl SqlxPostgresConnector { /// Check if the URI provided corresponds to `postgres://` for a PostgreSQL database - #[cfg(feature = "mock")] + #[allow(unused_variables)] pub fn accepts(string: &str) -> bool { string.starts_with("postgres://") && string.parse::().is_ok() } diff --git a/src/driver/sqlx_sqlite.rs b/src/driver/sqlx_sqlite.rs index 5fa02dd11..9ab2571fd 100644 --- a/src/driver/sqlx_sqlite.rs +++ b/src/driver/sqlx_sqlite.rs @@ -36,7 +36,7 @@ impl std::fmt::Debug for SqlxSqlitePoolConnection { impl SqlxSqliteConnector { /// Check if the URI provided corresponds to `sqlite:` for a SQLite database - #[cfg(feature = "mock")] + #[allow(unused_variables)] pub fn accepts(string: &str) -> bool { string.starts_with("sqlite:") && string.parse::().is_ok() } From 20dc881d81bc7951c6efbfe4b8ba863f41b3f8a0 Mon Sep 17 00:00:00 2001 From: shogo-nakano-desu <61229807+shogo-nakano-desu@users.noreply.github.com> Date: Thu, 11 Jan 2024 00:06:40 +0900 Subject: [PATCH 20/20] chore: add #[allow(unused_imports)] for driver --- src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib.rs b/src/lib.rs index 4026b5636..65e0d1cac 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -345,6 +345,7 @@ pub mod tests_cfg; mod util; pub use database::*; +#[allow(unused_imports)] pub use driver::*; pub use entity::*; pub use error::*;