From ac804a16427afeb823dc6062260e29d24c63b99a Mon Sep 17 00:00:00 2001 From: Billy Chan Date: Wed, 10 Nov 2021 15:15:50 +0800 Subject: [PATCH 1/4] Imports `PaginatorTrait` by default making it backward compatible --- examples/actix4_example/src/main.rs | 2 +- examples/actix_example/src/main.rs | 2 +- examples/axum_example/src/main.rs | 2 +- examples/basic/src/select.rs | 2 +- examples/rocket_example/src/main.rs | 2 +- src/entity/mod.rs | 3 +++ src/entity/prelude.rs | 4 ++-- src/executor/paginator.rs | 4 ++-- tests/basic.rs | 4 +--- tests/crud/updates.rs | 2 +- 10 files changed, 14 insertions(+), 13 deletions(-) diff --git a/examples/actix4_example/src/main.rs b/examples/actix4_example/src/main.rs index c30b20d74..6a52b81b1 100644 --- a/examples/actix4_example/src/main.rs +++ b/examples/actix4_example/src/main.rs @@ -5,7 +5,7 @@ use actix_web::{ use listenfd::ListenFd; use sea_orm::DatabaseConnection; -use sea_orm::{entity::*, query::*, PaginatorTrait}; +use sea_orm::{entity::*, query::*}; use serde::{Deserialize, Serialize}; use std::env; use tera::Tera; diff --git a/examples/actix_example/src/main.rs b/examples/actix_example/src/main.rs index e7bae5074..e2d1e9566 100644 --- a/examples/actix_example/src/main.rs +++ b/examples/actix_example/src/main.rs @@ -4,7 +4,7 @@ use actix_web::{ }; use listenfd::ListenFd; use sea_orm::DatabaseConnection; -use sea_orm::{entity::*, query::*, PaginatorTrait}; +use sea_orm::{entity::*, query::*}; use serde::{Deserialize, Serialize}; use std::env; use tera::Tera; diff --git a/examples/axum_example/src/main.rs b/examples/axum_example/src/main.rs index fd07fa720..7b0b428e0 100644 --- a/examples/axum_example/src/main.rs +++ b/examples/axum_example/src/main.rs @@ -12,7 +12,7 @@ use axum::{ }; use flash::{get_flash_cookie, post_response, PostResponse}; use post::Entity as Post; -use sea_orm::{prelude::*, Database, QueryOrder, Set, PaginatorTrait}; +use sea_orm::{prelude::*, Database, QueryOrder, Set}; use serde::{Deserialize, Serialize}; use std::str::FromStr; use std::{env, net::SocketAddr}; diff --git a/examples/basic/src/select.rs b/examples/basic/src/select.rs index ae7e1912a..ce26f9e20 100644 --- a/examples/basic/src/select.rs +++ b/examples/basic/src/select.rs @@ -1,5 +1,5 @@ use super::*; -use sea_orm::{entity::*, error::*, query::*, DbConn, FromQueryResult, PaginatorTrait}; +use sea_orm::{entity::*, error::*, query::*, DbConn, FromQueryResult}; pub async fn all_about_select(db: &DbConn) -> Result<(), DbErr> { find_all(db).await?; diff --git a/examples/rocket_example/src/main.rs b/examples/rocket_example/src/main.rs index df3e841f1..e0b01bea5 100644 --- a/examples/rocket_example/src/main.rs +++ b/examples/rocket_example/src/main.rs @@ -9,7 +9,7 @@ use rocket::response::{Flash, Redirect}; use rocket::{Build, Request, Rocket}; use rocket_dyn_templates::{context, Template}; -use sea_orm::{entity::*, query::*, PaginatorTrait}; +use sea_orm::{entity::*, query::*}; use sea_orm_rocket::{Connection, Database}; mod pool; diff --git a/src/entity/mod.rs b/src/entity/mod.rs index 6b413bdf1..f85f1ee19 100644 --- a/src/entity/mod.rs +++ b/src/entity/mod.rs @@ -117,3 +117,6 @@ pub use model::*; // pub use prelude::*; pub use primary_key::*; pub use relation::*; + +// Imports paginator utility by default making it backward compatible. +pub use crate::PaginatorTrait; diff --git a/src/entity/prelude.rs b/src/entity/prelude.rs index 211cf853d..28f5fe708 100644 --- a/src/entity/prelude.rs +++ b/src/entity/prelude.rs @@ -1,8 +1,8 @@ pub use crate::{ error::*, ActiveEnum, ActiveModelBehavior, ActiveModelTrait, ColumnDef, ColumnTrait, ColumnType, DatabaseConnection, DbConn, EntityName, EntityTrait, EnumIter, ForeignKeyAction, - Iden, IdenStatic, Linked, ModelTrait, PrimaryKeyToColumn, PrimaryKeyTrait, QueryFilter, - QueryResult, Related, RelationDef, RelationTrait, Select, Value, + Iden, IdenStatic, Linked, ModelTrait, PaginatorTrait, PrimaryKeyToColumn, PrimaryKeyTrait, + QueryFilter, QueryResult, Related, RelationDef, RelationTrait, Select, Value, }; #[cfg(feature = "macros")] diff --git a/src/executor/paginator.rs b/src/executor/paginator.rs index 7216d45cf..c8bd503a3 100644 --- a/src/executor/paginator.rs +++ b/src/executor/paginator.rs @@ -98,7 +98,7 @@ where /// /// ```rust /// # #[cfg(feature = "mock")] - /// # use sea_orm::{error::*, MockDatabase, DbBackend, PaginatorTrait}; + /// # use sea_orm::{error::*, MockDatabase, DbBackend}; /// # let owned_db = MockDatabase::new(DbBackend::Postgres).into_connection(); /// # let db = &owned_db; /// # let _: Result<(), DbErr> = smol::block_on(async { @@ -126,7 +126,7 @@ where /// /// ```rust /// # #[cfg(feature = "mock")] - /// # use sea_orm::{error::*, MockDatabase, DbBackend, PaginatorTrait}; + /// # use sea_orm::{error::*, MockDatabase, DbBackend}; /// # let owned_db = MockDatabase::new(DbBackend::Postgres).into_connection(); /// # let db = &owned_db; /// # let _: Result<(), DbErr> = smol::block_on(async { diff --git a/tests/basic.rs b/tests/basic.rs index 4b6f5b0cd..ef379779e 100644 --- a/tests/basic.rs +++ b/tests/basic.rs @@ -1,8 +1,6 @@ pub mod common; -pub use sea_orm::{ - entity::*, error::*, query::*, sea_query, tests_cfg::*, Database, DbConn, PaginatorTrait, -}; +pub use sea_orm::{entity::*, error::*, query::*, sea_query, tests_cfg::*, Database, DbConn}; // cargo test --features sqlx-sqlite,runtime-async-std-native-tls --test basic #[sea_orm_macros::test] diff --git a/tests/crud/updates.rs b/tests/crud/updates.rs index 4a3a05a03..262031ef3 100644 --- a/tests/crud/updates.rs +++ b/tests/crud/updates.rs @@ -1,6 +1,6 @@ pub use super::*; use rust_decimal_macros::dec; -use sea_orm::{DbErr, PaginatorTrait}; +use sea_orm::DbErr; use uuid::Uuid; pub async fn test_update_cake(db: &DbConn) { From 9c1646b1985cd6e0effc48e9223fd091df5d17da Mon Sep 17 00:00:00 2001 From: Billy Chan Date: Wed, 10 Nov 2021 15:53:37 +0800 Subject: [PATCH 2/4] Fixup --- src/entity/mod.rs | 3 --- src/query/mod.rs | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/entity/mod.rs b/src/entity/mod.rs index f85f1ee19..6b413bdf1 100644 --- a/src/entity/mod.rs +++ b/src/entity/mod.rs @@ -117,6 +117,3 @@ pub use model::*; // pub use prelude::*; pub use primary_key::*; pub use relation::*; - -// Imports paginator utility by default making it backward compatible. -pub use crate::PaginatorTrait; diff --git a/src/query/mod.rs b/src/query/mod.rs index fcf8b1680..474fa5ba6 100644 --- a/src/query/mod.rs +++ b/src/query/mod.rs @@ -23,3 +23,6 @@ pub use update::*; pub use util::*; pub use crate::{ConnectionTrait, InsertResult, Statement, UpdateResult, Value, Values}; + +// Imports paginator utility by default making it backward compatible. +pub use crate::PaginatorTrait; From f975223d9ee3f3868636b258ab3d3b78948e8304 Mon Sep 17 00:00:00 2001 From: Billy Chan Date: Wed, 10 Nov 2021 16:08:06 +0800 Subject: [PATCH 3/4] Fixup --- tests/crud/updates.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/crud/updates.rs b/tests/crud/updates.rs index 262031ef3..55af604e0 100644 --- a/tests/crud/updates.rs +++ b/tests/crud/updates.rs @@ -1,6 +1,6 @@ pub use super::*; use rust_decimal_macros::dec; -use sea_orm::DbErr; +use sea_orm::{query::*, DbErr}; use uuid::Uuid; pub async fn test_update_cake(db: &DbConn) { From a95d99e186b28c7f046e30ce9d9c02b3bf27a712 Mon Sep 17 00:00:00 2001 From: Billy Chan Date: Thu, 11 Nov 2021 12:12:53 +0800 Subject: [PATCH 4/4] Refactoring --- src/query/mod.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/query/mod.rs b/src/query/mod.rs index 474fa5ba6..3168e81ea 100644 --- a/src/query/mod.rs +++ b/src/query/mod.rs @@ -22,7 +22,6 @@ pub use traits::*; pub use update::*; pub use util::*; -pub use crate::{ConnectionTrait, InsertResult, Statement, UpdateResult, Value, Values}; - -// Imports paginator utility by default making it backward compatible. -pub use crate::PaginatorTrait; +pub use crate::{ + ConnectionTrait, InsertResult, PaginatorTrait, Statement, UpdateResult, Value, Values, +};