diff --git a/Cargo.toml b/Cargo.toml index 39a5fc1a0..ade001a0b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,8 +34,8 @@ tracing = { version = "0.1", default-features = false, features = ["attributes", rust_decimal = { version = "1", default-features = false, optional = true } bigdecimal = { version = "0.3", default-features = false, optional = true } sea-orm-macros = { version = "0.12.0", path = "sea-orm-macros", default-features = false, features = ["strum"] } -sea-query = { version = "0.29.0-rc.1", features = ["thread-safe"] } -sea-query-binder = { version = "0.4.0-rc.1", default-features = false, optional = true } +sea-query = { version = "0.29.0-rc.2", features = ["thread-safe"] } +sea-query-binder = { version = "0.4.0-rc.2", default-features = false, optional = true } strum = { version = "0.24", default-features = false } serde = { version = "1.0", default-features = false } serde_json = { version = "1.0", default-features = false, optional = true } diff --git a/sea-orm-cli/Cargo.toml b/sea-orm-cli/Cargo.toml index ecaad783b..e40061eed 100644 --- a/sea-orm-cli/Cargo.toml +++ b/sea-orm-cli/Cargo.toml @@ -38,7 +38,7 @@ clap = { version = "3.2", default-features = false, features = ["std", "env", "d dotenvy = { version = "0.15", default-features = false, optional = true } async-std = { version = "1.9", default-features = false, features = ["attributes", "tokio1"], optional = true } sea-orm-codegen = { version = "=0.12.0", path = "../sea-orm-codegen", default-features = false, optional = true } -sea-schema = { version = "0.12.0-rc.1" } +sea-schema = { version = "0.12.0-rc.2" } 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 = { version = "0.1", default-features = false } diff --git a/sea-orm-codegen/Cargo.toml b/sea-orm-codegen/Cargo.toml index f51a6ef79..c3efc08da 100644 --- a/sea-orm-codegen/Cargo.toml +++ b/sea-orm-codegen/Cargo.toml @@ -17,7 +17,7 @@ name = "sea_orm_codegen" path = "src/lib.rs" [dependencies] -sea-query = { version = "0.29.0-rc.1", default-features = false, features = ["thread-safe"] } +sea-query = { version = "0.29.0-rc.2", default-features = false, features = ["thread-safe"] } syn = { version = "1", default-features = false, features = ["parsing", "proc-macro", "derive", "printing"] } quote = { version = "1", default-features = false } heck = { version = "0.4", default-features = false } diff --git a/sea-orm-codegen/src/entity/column.rs b/sea-orm-codegen/src/entity/column.rs index cacba3e14..50582c27f 100644 --- a/sea-orm-codegen/src/entity/column.rs +++ b/sea-orm-codegen/src/entity/column.rs @@ -178,7 +178,7 @@ impl Column { } ColumnType::Array(column_type) => { let column_type = write_col_def(column_type); - quote! { ColumnType::Array(sea_orm::sea_query::SeaRc::new(#column_type)) } + quote! { ColumnType::Array(RcOrArc::new(#column_type)) } } #[allow(unreachable_patterns)] _ => unimplemented!(), diff --git a/sea-orm-codegen/src/entity/writer.rs b/sea-orm-codegen/src/entity/writer.rs index 606e3389a..6338f1a13 100644 --- a/sea-orm-codegen/src/entity/writer.rs +++ b/sea-orm-codegen/src/entity/writer.rs @@ -785,7 +785,7 @@ mod tests { }; use pretty_assertions::assert_eq; use proc_macro2::TokenStream; - use sea_query::{ColumnType, ForeignKeyAction, SeaRc}; + use sea_query::{ColumnType, ForeignKeyAction, RcOrArc}; use std::io::{self, BufRead, BufReader, Read}; fn setup() -> Vec { @@ -1258,14 +1258,14 @@ mod tests { }, Column { name: "integers".to_owned(), - col_type: ColumnType::Array(SeaRc::new(ColumnType::Integer)), + col_type: ColumnType::Array(RcOrArc::new(ColumnType::Integer)), auto_increment: false, not_null: true, unique: false, }, Column { name: "integers_opt".to_owned(), - col_type: ColumnType::Array(SeaRc::new(ColumnType::Integer)), + col_type: ColumnType::Array(RcOrArc::new(ColumnType::Integer)), auto_increment: false, not_null: false, unique: false, @@ -1289,14 +1289,14 @@ mod tests { }, Column { name: "floats".to_owned(), - col_type: ColumnType::Array(SeaRc::new(ColumnType::Float)), + col_type: ColumnType::Array(RcOrArc::new(ColumnType::Float)), auto_increment: false, not_null: true, unique: false, }, Column { name: "doubles".to_owned(), - col_type: ColumnType::Array(SeaRc::new(ColumnType::Double)), + col_type: ColumnType::Array(RcOrArc::new(ColumnType::Double)), auto_increment: false, not_null: true, unique: false, diff --git a/sea-orm-codegen/tests/expanded/collection.rs b/sea-orm-codegen/tests/expanded/collection.rs index 1414dfc43..fce6642ef 100644 --- a/sea-orm-codegen/tests/expanded/collection.rs +++ b/sea-orm-codegen/tests/expanded/collection.rs @@ -45,8 +45,8 @@ impl ColumnTrait for Column { fn def(&self) -> ColumnDef { match self { Self::Id => ColumnType::Integer.def(), - Self::Integers => ColumnType::Array(sea_orm::sea_query::SeaRc::new(ColumnType::Integer)).def(), - Self::IntegersOpt => ColumnType::Array(sea_orm::sea_query::SeaRc::new(ColumnType::Integer)).def().null(), + Self::Integers => ColumnType::Array(RcOrArc::new(ColumnType::Integer)).def(), + Self::IntegersOpt => ColumnType::Array(RcOrArc::new(ColumnType::Integer)).def().null(), } } } diff --git a/sea-orm-codegen/tests/expanded/collection_float.rs b/sea-orm-codegen/tests/expanded/collection_float.rs index b27d8f00d..6d6dff793 100644 --- a/sea-orm-codegen/tests/expanded/collection_float.rs +++ b/sea-orm-codegen/tests/expanded/collection_float.rs @@ -45,8 +45,8 @@ impl ColumnTrait for Column { fn def(&self) -> ColumnDef { match self { Self::Id => ColumnType::Integer.def(), - Self::Floats => ColumnType::Array(sea_orm::sea_query::SeaRc::new(ColumnType::Float)).def(), - Self::Doubles => ColumnType::Array(sea_orm::sea_query::SeaRc::new(ColumnType::Double)).def(), + Self::Floats => ColumnType::Array(RcOrArc::new(ColumnType::Float)).def(), + Self::Doubles => ColumnType::Array(RcOrArc::new(ColumnType::Double)).def(), } } } diff --git a/sea-orm-codegen/tests/expanded_with_schema_name/collection.rs b/sea-orm-codegen/tests/expanded_with_schema_name/collection.rs index b7b1cb8bf..8fdd54383 100644 --- a/sea-orm-codegen/tests/expanded_with_schema_name/collection.rs +++ b/sea-orm-codegen/tests/expanded_with_schema_name/collection.rs @@ -49,8 +49,8 @@ impl ColumnTrait for Column { fn def(&self) -> ColumnDef { match self { Self::Id => ColumnType::Integer.def(), - Self::Integers => ColumnType::Array(sea_orm::sea_query::SeaRc::new(ColumnType::Integer)).def(), - Self::IntegersOpt => ColumnType::Array(sea_orm::sea_query::SeaRc::new(ColumnType::Integer)).def().null(), + Self::Integers => ColumnType::Array(RcOrArc::new(ColumnType::Integer)).def(), + Self::IntegersOpt => ColumnType::Array(RcOrArc::new(ColumnType::Integer)).def().null(), } } } diff --git a/sea-orm-codegen/tests/expanded_with_schema_name/collection_float.rs b/sea-orm-codegen/tests/expanded_with_schema_name/collection_float.rs index 2413f3e02..02a0bf6c6 100644 --- a/sea-orm-codegen/tests/expanded_with_schema_name/collection_float.rs +++ b/sea-orm-codegen/tests/expanded_with_schema_name/collection_float.rs @@ -49,8 +49,8 @@ impl ColumnTrait for Column { fn def(&self) -> ColumnDef { match self { Self::Id => ColumnType::Integer.def(), - Self::Floats => ColumnType::Array(sea_orm::sea_query::SeaRc::new(ColumnType::Float)).def(), - Self::Doubles => ColumnType::Array(sea_orm::sea_query::SeaRc::new(ColumnType::Double)).def(), + Self::Floats => ColumnType::Array(RcOrArc::new(ColumnType::Float)).def(), + Self::Doubles => ColumnType::Array(RcOrArc::new(ColumnType::Double)).def(), } } } diff --git a/sea-orm-migration/Cargo.toml b/sea-orm-migration/Cargo.toml index 60da77ce2..a77eb316c 100644 --- a/sea-orm-migration/Cargo.toml +++ b/sea-orm-migration/Cargo.toml @@ -25,7 +25,7 @@ clap = { version = "3.2", default-features = false, features = ["std", "env", "d dotenvy = { version = "0.15", default-features = false, optional = true } sea-orm = { version = "0.12.0", path = "../", default-features = false, features = ["macros"] } sea-orm-cli = { version = "0.12.0", path = "../sea-orm-cli", default-features = false, optional = true } -sea-schema = { version = "0.12.0-rc.1" } +sea-schema = { version = "0.12.0-rc.2" } tracing = { version = "0.1", default-features = false, features = ["log"] } tracing-subscriber = { version = "0.3.17", default-features = false, features = ["env-filter", "fmt"] } futures = { version = "0.3", default-features = false, features = ["std"] } diff --git a/src/entity/active_enum.rs b/src/entity/active_enum.rs index 3a89c603e..27bc894d0 100644 --- a/src/entity/active_enum.rs +++ b/src/entity/active_enum.rs @@ -14,10 +14,7 @@ use sea_query::{DynIden, Expr, Nullable, SimpleExpr, Value, ValueType}; /// > See [DeriveActiveEnum](sea_orm_macros::DeriveActiveEnum) for the full specification of macro attributes. /// /// ```rust -/// use sea_orm::{ -/// entity::prelude::*, -/// sea_query::{DynIden, SeaRc}, -/// }; +/// use sea_orm::entity::prelude::*; /// /// // Using the derive macro /// #[derive(Debug, PartialEq, EnumIter, DeriveActiveEnum)] diff --git a/src/entity/prelude.rs b/src/entity/prelude.rs index 85cd37420..18d17b797 100644 --- a/src/entity/prelude.rs +++ b/src/entity/prelude.rs @@ -1,9 +1,11 @@ pub use crate::{ - error::*, sea_query::BlobSize, ActiveEnum, ActiveModelBehavior, ActiveModelTrait, ColumnDef, - ColumnTrait, ColumnType, ColumnTypeTrait, ConnectionTrait, CursorTrait, DatabaseConnection, - DbConn, EntityName, EntityTrait, EnumIter, ForeignKeyAction, Iden, IdenStatic, Linked, - LoaderTrait, ModelTrait, PaginatorTrait, PrimaryKeyToColumn, PrimaryKeyTrait, QueryFilter, - QueryResult, Related, RelationDef, RelationTrait, Select, Value, + error::*, + sea_query::{BlobSize, DynIden, RcOrArc, SeaRc}, + ActiveEnum, ActiveModelBehavior, ActiveModelTrait, ColumnDef, ColumnTrait, ColumnType, + ColumnTypeTrait, ConnectionTrait, CursorTrait, DatabaseConnection, DbConn, EntityName, + EntityTrait, EnumIter, ForeignKeyAction, Iden, IdenStatic, Linked, LoaderTrait, ModelTrait, + PaginatorTrait, PrimaryKeyToColumn, PrimaryKeyTrait, QueryFilter, QueryResult, Related, + RelationDef, RelationTrait, Select, Value, }; #[cfg(feature = "macros")] diff --git a/tests/bits_tests.rs b/tests/bits_tests.rs index b6975be2a..3ef12b9a7 100644 --- a/tests/bits_tests.rs +++ b/tests/bits_tests.rs @@ -1,13 +1,13 @@ pub mod common; -use common::{features::*, TestContext}; +use common::features::*; use pretty_assertions::assert_eq; use sea_orm::{entity::prelude::*, entity::*, DatabaseConnection}; #[sea_orm_macros::test] #[cfg(feature = "sqlx-postgres")] async fn main() -> Result<(), DbErr> { - let ctx = TestContext::new("bits_tests").await; + let ctx = common::TestContext::new("bits_tests").await; create_tables(&ctx.db).await?; create_and_update(&ctx.db).await?; ctx.delete().await; diff --git a/tests/common/features/collection_expanded.rs b/tests/common/features/collection_expanded.rs new file mode 100644 index 000000000..b3cce1b7d --- /dev/null +++ b/tests/common/features/collection_expanded.rs @@ -0,0 +1,64 @@ +use sea_orm::entity::prelude::*; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn schema_name(&self) -> Option<&str> { + Some("schema_name") + } + + fn table_name(&self) -> &str { + "collection" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq)] +pub struct Model { + pub id: i32, + pub integers: Vec, + pub integers_opt: Option>, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + Integers, + IntegersOpt, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = i32; + fn auto_increment() -> bool { + true + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation {} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::Integer.def(), + Self::Integers => ColumnType::Array(RcOrArc::new(ColumnType::Integer)).def(), + Self::IntegersOpt => ColumnType::Array(RcOrArc::new(ColumnType::Integer)) + .def() + .null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + panic!("No RelationDef") + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/tests/common/features/event_trigger.rs b/tests/common/features/event_trigger.rs index d5f96b87b..bdda7f45b 100644 --- a/tests/common/features/event_trigger.rs +++ b/tests/common/features/event_trigger.rs @@ -1,6 +1,6 @@ use sea_orm::entity::prelude::*; use sea_orm::{ - sea_query::{ArrayType, ColumnType, SeaRc, ValueType}, + sea_query::{ArrayType, ColumnType, ValueType}, TryGetError, TryGetable, }; @@ -65,6 +65,6 @@ impl ValueType for Events { } fn column_type() -> ColumnType { - ColumnType::Array(SeaRc::new(ColumnType::String(None))) + ColumnType::Array(RcOrArc::new(ColumnType::String(None))) } } diff --git a/tests/common/features/mod.rs b/tests/common/features/mod.rs index 4a3895de5..8507b4e38 100644 --- a/tests/common/features/mod.rs +++ b/tests/common/features/mod.rs @@ -5,6 +5,7 @@ pub mod binary; pub mod bits; pub mod byte_primary_key; pub mod collection; +pub mod collection_expanded; pub mod custom_active_model; pub mod dyn_table_name_lazy_static; pub mod edit_log; @@ -30,6 +31,7 @@ pub use binary::Entity as Binary; pub use bits::Entity as Bits; pub use byte_primary_key::Entity as BytePrimaryKey; pub use collection::Entity as Collection; +pub use collection_expanded::Entity as CollectionExpanded; pub use dyn_table_name_lazy_static::Entity as DynTableNameLazyStatic; pub use edit_log::Entity as EditLog; pub use event_trigger::Entity as EventTrigger; diff --git a/tests/dyn_table_name_tests.rs b/tests/dyn_table_name_tests.rs index b71baa7b3..f95d3a2ef 100644 --- a/tests/dyn_table_name_tests.rs +++ b/tests/dyn_table_name_tests.rs @@ -6,7 +6,7 @@ use sea_orm::{ entity::prelude::*, DatabaseConnection, Delete, IntoActiveModel, Iterable, QueryTrait, Set, Update, }; -use sea_query::{Expr, IntoIden, Query}; +use sea_query::{Expr, Query}; #[sea_orm_macros::test] #[cfg(any(