From dd4bb02ee350363a72adc0f5bd0bc656d24a0af7 Mon Sep 17 00:00:00 2001 From: Diwakar Gupta <39624018+Diwakar-Gupta@users.noreply.github.com> Date: Sun, 12 Feb 2023 22:44:26 +0530 Subject: [PATCH 01/12] Add default_expr support for ColumnDef --- sea-orm-macros/src/derives/entity_model.rs | 14 ++++++++++++-- src/entity/column.rs | 15 ++++++++++++--- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/sea-orm-macros/src/derives/entity_model.rs b/sea-orm-macros/src/derives/entity_model.rs index 2b27121b0..0db197b19 100644 --- a/sea-orm-macros/src/derives/entity_model.rs +++ b/sea-orm-macros/src/derives/entity_model.rs @@ -152,7 +152,17 @@ pub fn expand_derive_entity_model(data: Data, attrs: Vec) -> syn::Res } else if name == "default_value" { default_value = Some(nv.lit.to_owned()); } else if name == "default_expr" { - default_expr = Some(nv.lit.to_owned()); + if let Lit::Str(litstr) = &nv.lit { + let value_expr: TokenStream = + syn::parse_str(&litstr.value())?; + + default_expr = Some(value_expr); + } else { + return Err(Error::new( + field.span(), + "`default_expr` should be str", + )); + } } else if name == "column_name" { if let Lit::Str(litstr) = &nv.lit { column_name = Some(litstr.value()); @@ -335,7 +345,7 @@ pub fn expand_derive_entity_model(data: Data, attrs: Vec) -> syn::Res match_row = quote! { #match_row.default_value(#default_value) }; } if let Some(default_expr) = default_expr { - match_row = quote! { #match_row.default_expr(#default_expr) }; + match_row = quote! { #match_row.default_value(#default_expr) }; } columns_trait.push(match_row); } diff --git a/src/entity/column.rs b/src/entity/column.rs index 991aa6995..071058917 100644 --- a/src/entity/column.rs +++ b/src/entity/column.rs @@ -9,13 +9,13 @@ use std::str::FromStr; pub use sea_query::ColumnType; /// Defines a Column for an Entity -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone)] pub struct ColumnDef { pub(crate) col_type: ColumnType, pub(crate) null: bool, pub(crate) unique: bool, pub(crate) indexed: bool, - pub(crate) default_value: Option, + pub(crate) default_value: Option, } macro_rules! bind_oper { @@ -338,7 +338,7 @@ impl ColumnDef { /// Set the default value pub fn default_value(mut self, value: T) -> Self where - T: Into, + T: Into, { self.default_value = Some(value.into()); self @@ -464,6 +464,7 @@ mod tests { mod hello { use crate as sea_orm; use crate::entity::prelude::*; + use sea_query::Expr; #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] #[sea_orm(table_name = "hello")] @@ -487,6 +488,8 @@ mod tests { pub eight: u32, #[sea_orm(unique, indexed, nullable)] pub nine: u64, + #[sea_orm(default_expr = "Expr::current_timestamp()")] + pub ten: DateTimeUtc, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] @@ -528,6 +531,12 @@ mod tests { hello::Column::Nine.def(), ColumnType::BigUnsigned.def().unique().indexed().nullable() ); + assert_eq!( + hello::Column::Ten.def(), + ColumnType::TimestampWithTimeZone + .def() + .default_value(Expr::current_timestamp()) + ); } #[test] From 951df659346d8641c9d97caa724b8c224fe34e50 Mon Sep 17 00:00:00 2001 From: Diwakar Gupta <39624018+Diwakar-Gupta@users.noreply.github.com> Date: Wed, 8 Mar 2023 14:06:29 +0530 Subject: [PATCH 02/12] added test for attribute `default_value` --- src/entity/column.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/entity/column.rs b/src/entity/column.rs index 071058917..6fd680898 100644 --- a/src/entity/column.rs +++ b/src/entity/column.rs @@ -490,6 +490,10 @@ mod tests { pub nine: u64, #[sea_orm(default_expr = "Expr::current_timestamp()")] pub ten: DateTimeUtc, + #[sea_orm(default_value = 7)] + pub eleven: u8, + #[sea_orm(default_value = "twelve_value")] + pub twelve: String, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] @@ -537,6 +541,14 @@ mod tests { .def() .default_value(Expr::current_timestamp()) ); + assert_eq!( + hello::Column::Eleven.def(), + ColumnType::TinyUnsigned.def().default_value(7) + ); + assert_eq!( + hello::Column::Twelve.def(), + ColumnType::String(None).def().default_value("twelve_value") + ); } #[test] From 57f2d77bb49b54aad903ad83ef9bc978bee3c66d Mon Sep 17 00:00:00 2001 From: Billy Chan Date: Thu, 23 Mar 2023 18:16:23 +0800 Subject: [PATCH 03/12] Implements `PartialEq` for `sea_query::SimpleExpr` --- Cargo.toml | 4 ++-- src/entity/column.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b2ae4abd0..5a9c783a8 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", git = "https://github.com/SeaQL/sea-query", branch = "impl-partial-eq-simple-expr", features = ["thread-safe"] } +sea-query-binder = { version = "0.4", git = "https://github.com/SeaQL/sea-query", branch = "impl-partial-eq-simple-expr", 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/src/entity/column.rs b/src/entity/column.rs index ebb486cfc..eabf5d4ca 100644 --- a/src/entity/column.rs +++ b/src/entity/column.rs @@ -9,7 +9,7 @@ use std::str::FromStr; pub use sea_query::ColumnType; /// Defines a Column for an Entity -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq)] pub struct ColumnDef { pub(crate) col_type: ColumnType, pub(crate) null: bool, From b33ac0904fc5448bd8281107fbebede970daefd6 Mon Sep 17 00:00:00 2001 From: Billy Chan Date: Thu, 23 Mar 2023 18:15:07 +0800 Subject: [PATCH 04/12] RcOrArc --- tests/common/features/event_trigger.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/common/features/event_trigger.rs b/tests/common/features/event_trigger.rs index d5f96b87b..323e455e9 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, RcOrArc, 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))) } } From 2029220f5ce2da3590081d3d05fca4998fa9295a Mon Sep 17 00:00:00 2001 From: Billy Chan Date: Thu, 23 Mar 2023 18:15:45 +0800 Subject: [PATCH 05/12] Re-export `sea_query::Expr` in `sea_orm::entity::prelude` --- src/entity/column.rs | 3 +-- src/entity/prelude.rs | 12 +++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/entity/column.rs b/src/entity/column.rs index eabf5d4ca..cde39ccf4 100644 --- a/src/entity/column.rs +++ b/src/entity/column.rs @@ -459,12 +459,11 @@ mod tests { #[test] #[cfg(feature = "macros")] fn entity_model_column_1() { - use crate::entity::*; + use crate::prelude::*; mod hello { use crate as sea_orm; use crate::entity::prelude::*; - use sea_query::Expr; #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] #[sea_orm(table_name = "hello")] diff --git a/src/entity/prelude.rs b/src/entity/prelude.rs index 85cd37420..98f72a365 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, Expr}, + 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")] From ff5a1175e1c880f01a463ff8dcb18776790e6824 Mon Sep 17 00:00:00 2001 From: Diwakar Gupta <39624018+Diwakar-Gupta@users.noreply.github.com> Date: Sun, 12 Feb 2023 22:44:26 +0530 Subject: [PATCH 06/12] Add default_expr support for ColumnDef --- sea-orm-macros/src/derives/entity_model.rs | 14 ++++++++++++-- src/entity/column.rs | 15 ++++++++++++--- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/sea-orm-macros/src/derives/entity_model.rs b/sea-orm-macros/src/derives/entity_model.rs index e50b8a66d..d7c16bcc7 100644 --- a/sea-orm-macros/src/derives/entity_model.rs +++ b/sea-orm-macros/src/derives/entity_model.rs @@ -156,7 +156,17 @@ pub fn expand_derive_entity_model(data: Data, attrs: Vec) -> syn::Res } else if name == "default_value" { default_value = Some(nv.lit.to_owned()); } else if name == "default_expr" { - default_expr = Some(nv.lit.to_owned()); + if let Lit::Str(litstr) = &nv.lit { + let value_expr: TokenStream = + syn::parse_str(&litstr.value())?; + + default_expr = Some(value_expr); + } else { + return Err(Error::new( + field.span(), + "`default_expr` should be str", + )); + } } else if name == "column_name" { if let Lit::Str(litstr) = &nv.lit { column_name = Some(litstr.value()); @@ -342,7 +352,7 @@ pub fn expand_derive_entity_model(data: Data, attrs: Vec) -> syn::Res match_row = quote! { #match_row.default_value(#default_value) }; } if let Some(default_expr) = default_expr { - match_row = quote! { #match_row.default_expr(#default_expr) }; + match_row = quote! { #match_row.default_value(#default_expr) }; } columns_trait.push(match_row); } diff --git a/src/entity/column.rs b/src/entity/column.rs index 1cf2e61b8..cabc95826 100644 --- a/src/entity/column.rs +++ b/src/entity/column.rs @@ -9,13 +9,13 @@ use std::str::FromStr; pub use sea_query::ColumnType; /// Defines a Column for an Entity -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone)] pub struct ColumnDef { pub(crate) col_type: ColumnType, pub(crate) null: bool, pub(crate) unique: bool, pub(crate) indexed: bool, - pub(crate) default_value: Option, + pub(crate) default_value: Option, } macro_rules! bind_oper { @@ -338,7 +338,7 @@ impl ColumnDef { /// Set the default value pub fn default_value(mut self, value: T) -> Self where - T: Into, + T: Into, { self.default_value = Some(value.into()); self @@ -464,6 +464,7 @@ mod tests { mod hello { use crate as sea_orm; use crate::entity::prelude::*; + use sea_query::Expr; #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] #[sea_orm(table_name = "hello")] @@ -487,6 +488,8 @@ mod tests { pub eight: u32, #[sea_orm(unique, indexed, nullable)] pub nine: u64, + #[sea_orm(default_expr = "Expr::current_timestamp()")] + pub ten: DateTimeUtc, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] @@ -528,6 +531,12 @@ mod tests { hello::Column::Nine.def(), ColumnType::BigUnsigned.def().unique().indexed().nullable() ); + assert_eq!( + hello::Column::Ten.def(), + ColumnType::TimestampWithTimeZone + .def() + .default_value(Expr::current_timestamp()) + ); } #[test] From e5c7c85a46c525869e08bfc5e392b105fd37e7a1 Mon Sep 17 00:00:00 2001 From: Diwakar Gupta <39624018+Diwakar-Gupta@users.noreply.github.com> Date: Wed, 8 Mar 2023 14:06:29 +0530 Subject: [PATCH 07/12] added test for attribute `default_value` --- src/entity/column.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/entity/column.rs b/src/entity/column.rs index cabc95826..ebb486cfc 100644 --- a/src/entity/column.rs +++ b/src/entity/column.rs @@ -490,6 +490,10 @@ mod tests { pub nine: u64, #[sea_orm(default_expr = "Expr::current_timestamp()")] pub ten: DateTimeUtc, + #[sea_orm(default_value = 7)] + pub eleven: u8, + #[sea_orm(default_value = "twelve_value")] + pub twelve: String, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] @@ -537,6 +541,14 @@ mod tests { .def() .default_value(Expr::current_timestamp()) ); + assert_eq!( + hello::Column::Eleven.def(), + ColumnType::TinyUnsigned.def().default_value(7) + ); + assert_eq!( + hello::Column::Twelve.def(), + ColumnType::String(None).def().default_value("twelve_value") + ); } #[test] From 6d971ff9786b4b38bee1835fc68409f32902cf5e Mon Sep 17 00:00:00 2001 From: Billy Chan Date: Thu, 23 Mar 2023 18:16:23 +0800 Subject: [PATCH 08/12] Implements `PartialEq` for `sea_query::SimpleExpr` --- Cargo.toml | 4 ++-- src/entity/column.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b2ae4abd0..5a9c783a8 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", git = "https://github.com/SeaQL/sea-query", branch = "impl-partial-eq-simple-expr", features = ["thread-safe"] } +sea-query-binder = { version = "0.4", git = "https://github.com/SeaQL/sea-query", branch = "impl-partial-eq-simple-expr", 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/src/entity/column.rs b/src/entity/column.rs index ebb486cfc..eabf5d4ca 100644 --- a/src/entity/column.rs +++ b/src/entity/column.rs @@ -9,7 +9,7 @@ use std::str::FromStr; pub use sea_query::ColumnType; /// Defines a Column for an Entity -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq)] pub struct ColumnDef { pub(crate) col_type: ColumnType, pub(crate) null: bool, From 91174e710b501de44d1308c798bb8125445f5314 Mon Sep 17 00:00:00 2001 From: Billy Chan Date: Thu, 23 Mar 2023 18:15:07 +0800 Subject: [PATCH 09/12] RcOrArc --- tests/common/features/event_trigger.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/common/features/event_trigger.rs b/tests/common/features/event_trigger.rs index d5f96b87b..323e455e9 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, RcOrArc, 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))) } } From 89e358efb53115c466cf9329e24d29713bc9adb9 Mon Sep 17 00:00:00 2001 From: Billy Chan Date: Thu, 23 Mar 2023 18:15:45 +0800 Subject: [PATCH 10/12] Re-export `sea_query::Expr` in `sea_orm::entity::prelude` --- src/entity/column.rs | 3 +-- src/entity/prelude.rs | 12 +++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/entity/column.rs b/src/entity/column.rs index eabf5d4ca..cde39ccf4 100644 --- a/src/entity/column.rs +++ b/src/entity/column.rs @@ -459,12 +459,11 @@ mod tests { #[test] #[cfg(feature = "macros")] fn entity_model_column_1() { - use crate::entity::*; + use crate::prelude::*; mod hello { use crate as sea_orm; use crate::entity::prelude::*; - use sea_query::Expr; #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] #[sea_orm(table_name = "hello")] diff --git a/src/entity/prelude.rs b/src/entity/prelude.rs index 85cd37420..98f72a365 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, Expr}, + 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")] From dce1798ccfb921ba232cd90ae777c0124e41443d Mon Sep 17 00:00:00 2001 From: Billy Chan Date: Tue, 20 Jun 2023 11:00:54 +0800 Subject: [PATCH 11/12] Deprecate `ColumnDef::default_value()` --- src/entity/column.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/entity/column.rs b/src/entity/column.rs index 965ced48e..5b2f4390e 100644 --- a/src/entity/column.rs +++ b/src/entity/column.rs @@ -362,9 +362,13 @@ impl ColumnDef { } /// Set the default value + #[deprecated( + since = "0.12.0", + note = "Please use [`ColumnDef::default`]" + )] pub fn default_value(mut self, value: T) -> Self where - T: Into, + T: Into, { self.default_value = Some(value.into()); self From 5ee0a6fec541601ddc7b59f928181ec8fca29e4d Mon Sep 17 00:00:00 2001 From: Billy Chan Date: Tue, 20 Jun 2023 11:15:39 +0800 Subject: [PATCH 12/12] Add `ColumnDef::default()` --- sea-orm-macros/src/derives/entity_model.rs | 4 ++-- src/entity/column.rs | 26 +++++++++++++--------- src/schema/entity.rs | 4 ++-- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/sea-orm-macros/src/derives/entity_model.rs b/sea-orm-macros/src/derives/entity_model.rs index d7c16bcc7..760b9686d 100644 --- a/sea-orm-macros/src/derives/entity_model.rs +++ b/sea-orm-macros/src/derives/entity_model.rs @@ -349,10 +349,10 @@ pub fn expand_derive_entity_model(data: Data, attrs: Vec) -> syn::Res match_row = quote! { #match_row.unique() }; } if let Some(default_value) = default_value { - match_row = quote! { #match_row.default_value(#default_value) }; + match_row = quote! { #match_row.default(#default_value) }; } if let Some(default_expr) = default_expr { - match_row = quote! { #match_row.default_value(#default_expr) }; + match_row = quote! { #match_row.default(#default_expr) }; } columns_trait.push(match_row); } diff --git a/src/entity/column.rs b/src/entity/column.rs index 5b2f4390e..48a2c1875 100644 --- a/src/entity/column.rs +++ b/src/entity/column.rs @@ -15,7 +15,7 @@ pub struct ColumnDef { pub(crate) null: bool, pub(crate) unique: bool, pub(crate) indexed: bool, - pub(crate) default_value: Option, + pub(crate) default: Option, } macro_rules! bind_oper { @@ -310,7 +310,7 @@ impl ColumnTypeTrait for ColumnType { null: false, unique: false, indexed: false, - default_value: None, + default: None, } } @@ -362,15 +362,21 @@ impl ColumnDef { } /// Set the default value - #[deprecated( - since = "0.12.0", - note = "Please use [`ColumnDef::default`]" - )] + #[deprecated(since = "0.12.0", note = "Please use [`ColumnDef::default`]")] pub fn default_value(mut self, value: T) -> Self where T: Into, { - self.default_value = Some(value.into()); + self.default = Some(value.into().into()); + self + } + + /// Set the default value or expression of a column + pub fn default(mut self, default: T) -> Self + where + T: Into, + { + self.default = Some(default.into()); self } @@ -568,15 +574,15 @@ mod tests { hello::Column::Ten.def(), ColumnType::TimestampWithTimeZone .def() - .default_value(Expr::current_timestamp()) + .default(Expr::current_timestamp()) ); assert_eq!( hello::Column::Eleven.def(), - ColumnType::TinyUnsigned.def().default_value(7) + ColumnType::TinyUnsigned.def().default(7) ); assert_eq!( hello::Column::Twelve.def(), - ColumnType::String(None).def().default_value("twelve_value") + ColumnType::String(None).def().default("twelve_value") ); } diff --git a/src/schema/entity.rs b/src/schema/entity.rs index 7aaac164d..f6e9ead01 100644 --- a/src/schema/entity.rs +++ b/src/schema/entity.rs @@ -210,8 +210,8 @@ where if orm_column_def.unique { column_def.unique_key(); } - if let Some(value) = orm_column_def.default_value { - column_def.default(value); + if let Some(default) = orm_column_def.default { + column_def.default(default); } for primary_key in E::PrimaryKey::iter() { if column.to_string() == primary_key.into_column().to_string() {