From a349f13fd761291c723b855054a9e2dc81434aa5 Mon Sep 17 00:00:00 2001 From: "Lingxiang \"LinG\" Wang" Date: Sat, 24 Sep 2022 22:38:05 -0400 Subject: [PATCH] Struct / enum derive PartialEq should also derive Eq (#988) * add Eq * Fix clippy warnings * Fix test cases Co-authored-by: Billy Chan --- sea-orm-codegen/src/entity/active_enum.rs | 5 +- sea-orm-codegen/src/entity/base_entity.rs | 29 ++++- sea-orm-codegen/src/entity/writer.rs | 109 ++++++++++++++++-- sea-orm-codegen/tests/compact/cake.rs | 2 +- sea-orm-codegen/tests/compact/cake_filling.rs | 2 +- .../tests/compact/cake_with_double.rs | 37 ++++++ .../tests/compact/cake_with_float.rs | 37 ++++++ sea-orm-codegen/tests/compact/filling.rs | 2 +- sea-orm-codegen/tests/compact/fruit.rs | 2 +- sea-orm-codegen/tests/compact/rust_keyword.rs | 2 +- sea-orm-codegen/tests/compact/vendor.rs | 2 +- .../tests/compact_with_schema_name/cake.rs | 2 +- .../compact_with_schema_name/cake_filling.rs | 2 +- .../cake_with_double.rs | 37 ++++++ .../cake_with_float.rs | 37 ++++++ .../tests/compact_with_schema_name/filling.rs | 2 +- .../tests/compact_with_schema_name/fruit.rs | 2 +- .../compact_with_schema_name/rust_keyword.rs | 2 +- .../tests/compact_with_schema_name/vendor.rs | 2 +- .../tests/compact_with_serde/cake_both.rs | 2 +- .../compact_with_serde/cake_deserialize.rs | 2 +- .../tests/compact_with_serde/cake_none.rs | 2 +- .../compact_with_serde/cake_serialize.rs | 2 +- sea-orm-codegen/tests/expanded/cake.rs | 2 +- .../tests/expanded/cake_filling.rs | 2 +- .../tests/expanded/cake_with_double.rs | 80 +++++++++++++ .../tests/expanded/cake_with_float.rs | 80 +++++++++++++ sea-orm-codegen/tests/expanded/filling.rs | 2 +- sea-orm-codegen/tests/expanded/fruit.rs | 2 +- .../tests/expanded/rust_keyword.rs | 2 +- sea-orm-codegen/tests/expanded/vendor.rs | 2 +- .../tests/expanded_with_schema_name/cake.rs | 2 +- .../expanded_with_schema_name/cake_filling.rs | 2 +- .../cake_with_double.rs | 84 ++++++++++++++ .../cake_with_float.rs | 84 ++++++++++++++ .../expanded_with_schema_name/filling.rs | 2 +- .../tests/expanded_with_schema_name/fruit.rs | 2 +- .../expanded_with_schema_name/rust_keyword.rs | 2 +- .../tests/expanded_with_schema_name/vendor.rs | 2 +- .../tests/expanded_with_serde/cake_both.rs | 2 +- .../expanded_with_serde/cake_deserialize.rs | 2 +- .../tests/expanded_with_serde/cake_none.rs | 2 +- .../expanded_with_serde/cake_serialize.rs | 2 +- 43 files changed, 640 insertions(+), 43 deletions(-) create mode 100644 sea-orm-codegen/tests/compact/cake_with_double.rs create mode 100644 sea-orm-codegen/tests/compact/cake_with_float.rs create mode 100644 sea-orm-codegen/tests/compact_with_schema_name/cake_with_double.rs create mode 100644 sea-orm-codegen/tests/compact_with_schema_name/cake_with_float.rs create mode 100644 sea-orm-codegen/tests/expanded/cake_with_double.rs create mode 100644 sea-orm-codegen/tests/expanded/cake_with_float.rs create mode 100644 sea-orm-codegen/tests/expanded_with_schema_name/cake_with_double.rs create mode 100644 sea-orm-codegen/tests/expanded_with_schema_name/cake_with_float.rs diff --git a/sea-orm-codegen/src/entity/active_enum.rs b/sea-orm-codegen/src/entity/active_enum.rs index d4a7e600..ddcf2bdf 100644 --- a/sea-orm-codegen/src/entity/active_enum.rs +++ b/sea-orm-codegen/src/entity/active_enum.rs @@ -1,8 +1,9 @@ -use crate::WithSerde; use heck::CamelCase; use proc_macro2::TokenStream; use quote::{format_ident, quote}; +use crate::WithSerde; + #[derive(Clone, Debug)] pub struct ActiveEnum { pub(crate) enum_name: String, @@ -30,7 +31,7 @@ impl ActiveEnum { }; quote! { - #[derive(Debug, Clone, PartialEq, EnumIter, DeriveActiveEnum #copy_derive #extra_derive)] + #[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum #copy_derive #extra_derive)] #[sea_orm(rs_type = "String", db_type = "Enum", enum_name = #enum_name)] pub enum #enum_iden { #( diff --git a/sea-orm-codegen/src/entity/base_entity.rs b/sea-orm-codegen/src/entity/base_entity.rs index a745b1f7..7e2ef8a9 100644 --- a/sea-orm-codegen/src/entity/base_entity.rs +++ b/sea-orm-codegen/src/entity/base_entity.rs @@ -1,7 +1,10 @@ -use crate::{Column, ConjunctRelation, DateTimeCrate, PrimaryKey, Relation}; use heck::{CamelCase, SnakeCase}; use proc_macro2::{Ident, TokenStream}; use quote::format_ident; +use quote::quote; +use sea_query::ColumnType; + +use crate::{Column, ConjunctRelation, DateTimeCrate, PrimaryKey, Relation}; #[derive(Clone, Debug)] pub struct Entity { @@ -145,14 +148,29 @@ impl Entity { .map(|con_rel| con_rel.get_to_camel_case()) .collect() } + + pub fn get_eq_needed(&self) -> TokenStream { + self.columns + .iter() + .find(|column| { + matches!( + column.col_type, + ColumnType::Float(_) | ColumnType::Double(_) + ) + }) + // check if float or double exist. + // if exist, return nothing + .map_or(quote! {, Eq}, |_| quote! {}) + } } #[cfg(test)] mod tests { - use crate::{Column, DateTimeCrate, Entity, PrimaryKey, Relation, RelationType}; use quote::format_ident; use sea_query::{ColumnType, ForeignKeyAction}; + use crate::{Column, DateTimeCrate, Entity, PrimaryKey, Relation, RelationType}; + fn setup() -> Entity { Entity { table_name: "special_cake".to_owned(), @@ -416,4 +434,11 @@ mod tests { assert_eq!(elem, entity.conjunct_relations[i].get_to_camel_case()); } } + + #[test] + fn test_get_eq_needed() { + let entity = setup(); + + println!("entity: {:?}", entity.get_eq_needed()); + } } diff --git a/sea-orm-codegen/src/entity/writer.rs b/sea-orm-codegen/src/entity/writer.rs index be6954ca..c0a74e73 100644 --- a/sea-orm-codegen/src/entity/writer.rs +++ b/sea-orm-codegen/src/entity/writer.rs @@ -381,11 +381,11 @@ impl EntityWriter { ) -> TokenStream { let column_names_snake_case = entity.get_column_names_snake_case(); let column_rs_types = entity.get_column_rs_types(date_time_crate); - + let if_eq_needed = entity.get_eq_needed(); let extra_derive = with_serde.extra_derive(); quote! { - #[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel #extra_derive)] + #[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel #if_eq_needed #extra_derive)] pub struct Model { #(pub #column_names_snake_case: #column_rs_types,)* } @@ -567,6 +567,7 @@ impl EntityWriter { let table_name = entity.table_name.as_str(); let column_names_snake_case = entity.get_column_names_snake_case(); let column_rs_types = entity.get_column_rs_types(date_time_crate); + let if_eq_needed = entity.get_eq_needed(); let primary_keys: Vec = entity .primary_keys .iter() @@ -621,7 +622,7 @@ impl EntityWriter { let extra_derive = with_serde.extra_derive(); quote! { - #[derive(Clone, Debug, PartialEq, DeriveEntityModel #extra_derive)] + #[derive(Clone, Debug, PartialEq, DeriveEntityModel #if_eq_needed #extra_derive)] #[sea_orm( #schema_name table_name = #table_name @@ -1033,6 +1034,92 @@ mod tests { name: "id".to_owned(), }], }, + Entity { + table_name: "cake_with_float".to_owned(), + columns: vec![ + Column { + name: "id".to_owned(), + col_type: ColumnType::Integer(Some(11)), + auto_increment: true, + not_null: true, + unique: false, + }, + Column { + name: "name".to_owned(), + col_type: ColumnType::Text, + auto_increment: false, + not_null: false, + unique: false, + }, + Column { + name: "price".to_owned(), + col_type: ColumnType::Float(Some(2)), + auto_increment: false, + not_null: false, + unique: false, + }, + ], + relations: vec![Relation { + ref_table: "fruit".to_owned(), + columns: vec![], + ref_columns: vec![], + rel_type: RelationType::HasMany, + on_delete: None, + on_update: None, + self_referencing: false, + num_suffix: 0, + }], + conjunct_relations: vec![ConjunctRelation { + via: "cake_filling".to_owned(), + to: "filling".to_owned(), + }], + primary_keys: vec![PrimaryKey { + name: "id".to_owned(), + }], + }, + Entity { + table_name: "cake_with_double".to_owned(), + columns: vec![ + Column { + name: "id".to_owned(), + col_type: ColumnType::Integer(Some(11)), + auto_increment: true, + not_null: true, + unique: false, + }, + Column { + name: "name".to_owned(), + col_type: ColumnType::Text, + auto_increment: false, + not_null: false, + unique: false, + }, + Column { + name: "price".to_owned(), + col_type: ColumnType::Double(Some(2)), + auto_increment: false, + not_null: false, + unique: false, + }, + ], + relations: vec![Relation { + ref_table: "fruit".to_owned(), + columns: vec![], + ref_columns: vec![], + rel_type: RelationType::HasMany, + on_delete: None, + on_update: None, + self_referencing: false, + num_suffix: 0, + }], + conjunct_relations: vec![ConjunctRelation { + via: "cake_filling".to_owned(), + to: "filling".to_owned(), + }], + primary_keys: vec![PrimaryKey { + name: "id".to_owned(), + }], + }, ] } @@ -1057,21 +1144,25 @@ mod tests { #[test] fn test_gen_expanded_code_blocks() -> io::Result<()> { let entities = setup(); - const ENTITY_FILES: [&str; 6] = [ + const ENTITY_FILES: [&str; 8] = [ include_str!("../../tests/expanded/cake.rs"), include_str!("../../tests/expanded/cake_filling.rs"), include_str!("../../tests/expanded/filling.rs"), include_str!("../../tests/expanded/fruit.rs"), include_str!("../../tests/expanded/vendor.rs"), include_str!("../../tests/expanded/rust_keyword.rs"), + include_str!("../../tests/expanded/cake_with_float.rs"), + include_str!("../../tests/expanded/cake_with_double.rs"), ]; - const ENTITY_FILES_WITH_SCHEMA_NAME: [&str; 6] = [ + const ENTITY_FILES_WITH_SCHEMA_NAME: [&str; 8] = [ include_str!("../../tests/expanded_with_schema_name/cake.rs"), include_str!("../../tests/expanded_with_schema_name/cake_filling.rs"), include_str!("../../tests/expanded_with_schema_name/filling.rs"), include_str!("../../tests/expanded_with_schema_name/fruit.rs"), include_str!("../../tests/expanded_with_schema_name/vendor.rs"), include_str!("../../tests/expanded_with_schema_name/rust_keyword.rs"), + include_str!("../../tests/expanded_with_schema_name/cake_with_float.rs"), + include_str!("../../tests/expanded_with_schema_name/cake_with_double.rs"), ]; assert_eq!(entities.len(), ENTITY_FILES.len()); @@ -1133,21 +1224,25 @@ mod tests { #[test] fn test_gen_compact_code_blocks() -> io::Result<()> { let entities = setup(); - const ENTITY_FILES: [&str; 6] = [ + const ENTITY_FILES: [&str; 8] = [ include_str!("../../tests/compact/cake.rs"), include_str!("../../tests/compact/cake_filling.rs"), include_str!("../../tests/compact/filling.rs"), include_str!("../../tests/compact/fruit.rs"), include_str!("../../tests/compact/vendor.rs"), include_str!("../../tests/compact/rust_keyword.rs"), + include_str!("../../tests/compact/cake_with_float.rs"), + include_str!("../../tests/compact/cake_with_double.rs"), ]; - const ENTITY_FILES_WITH_SCHEMA_NAME: [&str; 6] = [ + const ENTITY_FILES_WITH_SCHEMA_NAME: [&str; 8] = [ include_str!("../../tests/compact_with_schema_name/cake.rs"), include_str!("../../tests/compact_with_schema_name/cake_filling.rs"), include_str!("../../tests/compact_with_schema_name/filling.rs"), include_str!("../../tests/compact_with_schema_name/fruit.rs"), include_str!("../../tests/compact_with_schema_name/vendor.rs"), include_str!("../../tests/compact_with_schema_name/rust_keyword.rs"), + include_str!("../../tests/compact_with_schema_name/cake_with_float.rs"), + include_str!("../../tests/compact_with_schema_name/cake_with_double.rs"), ]; assert_eq!(entities.len(), ENTITY_FILES.len()); diff --git a/sea-orm-codegen/tests/compact/cake.rs b/sea-orm-codegen/tests/compact/cake.rs index 2e26257c..7451140d 100644 --- a/sea-orm-codegen/tests/compact/cake.rs +++ b/sea-orm-codegen/tests/compact/cake.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "cake")] pub struct Model { #[sea_orm(primary_key)] diff --git a/sea-orm-codegen/tests/compact/cake_filling.rs b/sea-orm-codegen/tests/compact/cake_filling.rs index ba9ed2ca..de27153d 100644 --- a/sea-orm-codegen/tests/compact/cake_filling.rs +++ b/sea-orm-codegen/tests/compact/cake_filling.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "_cake_filling_")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/sea-orm-codegen/tests/compact/cake_with_double.rs b/sea-orm-codegen/tests/compact/cake_with_double.rs new file mode 100644 index 00000000..edf4a991 --- /dev/null +++ b/sea-orm-codegen/tests/compact/cake_with_double.rs @@ -0,0 +1,37 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.1.0 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] +#[sea_orm(table_name = "cake_with_double")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + #[sea_orm(column_type = "Text", nullable)] + pub name: Option , + #[sea_orm(column_type = "Double(Some(2))", nullable)] + pub price: Option , +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm(has_many = "super::fruit::Entity")] + Fruit, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Fruit.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::cake_filling::Relation::Filling.def() + } + fn via() -> Option { + Some(super::cake_filling::Relation::CakeWithDouble.def().rev()) + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/sea-orm-codegen/tests/compact/cake_with_float.rs b/sea-orm-codegen/tests/compact/cake_with_float.rs new file mode 100644 index 00000000..a5f9f701 --- /dev/null +++ b/sea-orm-codegen/tests/compact/cake_with_float.rs @@ -0,0 +1,37 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.1.0 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] +#[sea_orm(table_name = "cake_with_float")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + #[sea_orm(column_type = "Text", nullable)] + pub name: Option , + #[sea_orm(column_type = "Float(Some(2))", nullable)] + pub price: Option , +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm(has_many = "super::fruit::Entity")] + Fruit, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Fruit.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::cake_filling::Relation::Filling.def() + } + fn via() -> Option { + Some(super::cake_filling::Relation::CakeWithFloat.def().rev()) + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/sea-orm-codegen/tests/compact/filling.rs b/sea-orm-codegen/tests/compact/filling.rs index de92558e..58f5f05c 100644 --- a/sea-orm-codegen/tests/compact/filling.rs +++ b/sea-orm-codegen/tests/compact/filling.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "filling")] pub struct Model { #[sea_orm(primary_key)] diff --git a/sea-orm-codegen/tests/compact/fruit.rs b/sea-orm-codegen/tests/compact/fruit.rs index 6399a51f..6ead03d1 100644 --- a/sea-orm-codegen/tests/compact/fruit.rs +++ b/sea-orm-codegen/tests/compact/fruit.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "fruit")] pub struct Model { #[sea_orm(primary_key)] diff --git a/sea-orm-codegen/tests/compact/rust_keyword.rs b/sea-orm-codegen/tests/compact/rust_keyword.rs index c5d46f50..1daeba8e 100644 --- a/sea-orm-codegen/tests/compact/rust_keyword.rs +++ b/sea-orm-codegen/tests/compact/rust_keyword.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "rust_keyword")] pub struct Model { #[sea_orm(primary_key)] diff --git a/sea-orm-codegen/tests/compact/vendor.rs b/sea-orm-codegen/tests/compact/vendor.rs index 1351c227..f14c2808 100644 --- a/sea-orm-codegen/tests/compact/vendor.rs +++ b/sea-orm-codegen/tests/compact/vendor.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "vendor")] pub struct Model { #[sea_orm(primary_key)] diff --git a/sea-orm-codegen/tests/compact_with_schema_name/cake.rs b/sea-orm-codegen/tests/compact_with_schema_name/cake.rs index d2efb986..b8418d64 100644 --- a/sea-orm-codegen/tests/compact_with_schema_name/cake.rs +++ b/sea-orm-codegen/tests/compact_with_schema_name/cake.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(schema_name = "schema_name", table_name = "cake")] pub struct Model { #[sea_orm(primary_key)] diff --git a/sea-orm-codegen/tests/compact_with_schema_name/cake_filling.rs b/sea-orm-codegen/tests/compact_with_schema_name/cake_filling.rs index a9704a8a..7ca8eb91 100644 --- a/sea-orm-codegen/tests/compact_with_schema_name/cake_filling.rs +++ b/sea-orm-codegen/tests/compact_with_schema_name/cake_filling.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(schema_name = "schema_name", table_name = "_cake_filling_")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/sea-orm-codegen/tests/compact_with_schema_name/cake_with_double.rs b/sea-orm-codegen/tests/compact_with_schema_name/cake_with_double.rs new file mode 100644 index 00000000..4afb7d6a --- /dev/null +++ b/sea-orm-codegen/tests/compact_with_schema_name/cake_with_double.rs @@ -0,0 +1,37 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.1.0 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] +#[sea_orm(schema_name = "schema_name", table_name = "cake_with_double")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + #[sea_orm(column_type = "Text", nullable)] + pub name: Option , + #[sea_orm(column_type = "Double(Some(2))", nullable)] + pub price: Option , +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm(has_many = "super::fruit::Entity")] + Fruit, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Fruit.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::cake_filling::Relation::Filling.def() + } + fn via() -> Option { + Some(super::cake_filling::Relation::CakeWithDouble.def().rev()) + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/sea-orm-codegen/tests/compact_with_schema_name/cake_with_float.rs b/sea-orm-codegen/tests/compact_with_schema_name/cake_with_float.rs new file mode 100644 index 00000000..cf84a0a3 --- /dev/null +++ b/sea-orm-codegen/tests/compact_with_schema_name/cake_with_float.rs @@ -0,0 +1,37 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.1.0 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] +#[sea_orm(schema_name = "schema_name", table_name = "cake_with_float")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + #[sea_orm(column_type = "Text", nullable)] + pub name: Option , + #[sea_orm(column_type = "Float(Some(2))", nullable)] + pub price: Option , +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm(has_many = "super::fruit::Entity")] + Fruit, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Fruit.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::cake_filling::Relation::Filling.def() + } + fn via() -> Option { + Some(super::cake_filling::Relation::CakeWithFloat.def().rev()) + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/sea-orm-codegen/tests/compact_with_schema_name/filling.rs b/sea-orm-codegen/tests/compact_with_schema_name/filling.rs index ead70acd..f68ca06c 100644 --- a/sea-orm-codegen/tests/compact_with_schema_name/filling.rs +++ b/sea-orm-codegen/tests/compact_with_schema_name/filling.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(schema_name = "schema_name", table_name = "filling")] pub struct Model { #[sea_orm(primary_key)] diff --git a/sea-orm-codegen/tests/compact_with_schema_name/fruit.rs b/sea-orm-codegen/tests/compact_with_schema_name/fruit.rs index 28104324..dc446b1d 100644 --- a/sea-orm-codegen/tests/compact_with_schema_name/fruit.rs +++ b/sea-orm-codegen/tests/compact_with_schema_name/fruit.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(schema_name = "schema_name", table_name = "fruit")] pub struct Model { #[sea_orm(primary_key)] diff --git a/sea-orm-codegen/tests/compact_with_schema_name/rust_keyword.rs b/sea-orm-codegen/tests/compact_with_schema_name/rust_keyword.rs index f3ca0314..014836ea 100644 --- a/sea-orm-codegen/tests/compact_with_schema_name/rust_keyword.rs +++ b/sea-orm-codegen/tests/compact_with_schema_name/rust_keyword.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(schema_name = "schema_name", table_name = "rust_keyword")] pub struct Model { #[sea_orm(primary_key)] diff --git a/sea-orm-codegen/tests/compact_with_schema_name/vendor.rs b/sea-orm-codegen/tests/compact_with_schema_name/vendor.rs index 85209c45..c3909880 100644 --- a/sea-orm-codegen/tests/compact_with_schema_name/vendor.rs +++ b/sea-orm-codegen/tests/compact_with_schema_name/vendor.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(schema_name = "schema_name", table_name = "vendor")] pub struct Model { #[sea_orm(primary_key)] diff --git a/sea-orm-codegen/tests/compact_with_serde/cake_both.rs b/sea-orm-codegen/tests/compact_with_serde/cake_both.rs index 3a1bea9a..54d3cd16 100644 --- a/sea-orm-codegen/tests/compact_with_serde/cake_both.rs +++ b/sea-orm-codegen/tests/compact_with_serde/cake_both.rs @@ -3,7 +3,7 @@ use sea_orm::entity::prelude:: * ; use serde::{Deserialize, Serialize}; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] #[sea_orm(table_name = "cake")] pub struct Model { #[sea_orm(primary_key)] diff --git a/sea-orm-codegen/tests/compact_with_serde/cake_deserialize.rs b/sea-orm-codegen/tests/compact_with_serde/cake_deserialize.rs index b36718f9..f11569e4 100644 --- a/sea-orm-codegen/tests/compact_with_serde/cake_deserialize.rs +++ b/sea-orm-codegen/tests/compact_with_serde/cake_deserialize.rs @@ -3,7 +3,7 @@ use sea_orm::entity::prelude:: * ; use serde::Deserialize; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Deserialize)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Deserialize)] #[sea_orm(table_name = "cake")] pub struct Model { #[sea_orm(primary_key)] diff --git a/sea-orm-codegen/tests/compact_with_serde/cake_none.rs b/sea-orm-codegen/tests/compact_with_serde/cake_none.rs index 809b9051..d72ea6b2 100644 --- a/sea-orm-codegen/tests/compact_with_serde/cake_none.rs +++ b/sea-orm-codegen/tests/compact_with_serde/cake_none.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude:: * ; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "cake")] pub struct Model { #[sea_orm(primary_key)] diff --git a/sea-orm-codegen/tests/compact_with_serde/cake_serialize.rs b/sea-orm-codegen/tests/compact_with_serde/cake_serialize.rs index 81cc3907..77af4c5a 100644 --- a/sea-orm-codegen/tests/compact_with_serde/cake_serialize.rs +++ b/sea-orm-codegen/tests/compact_with_serde/cake_serialize.rs @@ -3,7 +3,7 @@ use sea_orm::entity::prelude:: * ; use serde::Serialize; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize)] #[sea_orm(table_name = "cake")] pub struct Model { #[sea_orm(primary_key)] diff --git a/sea-orm-codegen/tests/expanded/cake.rs b/sea-orm-codegen/tests/expanded/cake.rs index 0b33b618..961b1919 100644 --- a/sea-orm-codegen/tests/expanded/cake.rs +++ b/sea-orm-codegen/tests/expanded/cake.rs @@ -11,7 +11,7 @@ impl EntityName for Entity { } } -#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq)] pub struct Model { pub id: i32, pub name: Option , diff --git a/sea-orm-codegen/tests/expanded/cake_filling.rs b/sea-orm-codegen/tests/expanded/cake_filling.rs index d100fa8c..92e157f2 100644 --- a/sea-orm-codegen/tests/expanded/cake_filling.rs +++ b/sea-orm-codegen/tests/expanded/cake_filling.rs @@ -11,7 +11,7 @@ impl EntityName for Entity { } } -#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq)] pub struct Model { pub cake_id: i32, pub filling_id: i32, diff --git a/sea-orm-codegen/tests/expanded/cake_with_double.rs b/sea-orm-codegen/tests/expanded/cake_with_double.rs new file mode 100644 index 00000000..d71a9fbd --- /dev/null +++ b/sea-orm-codegen/tests/expanded/cake_with_double.rs @@ -0,0 +1,80 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.1.0 + +use sea_orm::entity::prelude::*; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "cake_with_double" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] +pub struct Model { + pub id: i32, + pub name: Option , + pub price: Option , +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + Name, + Price, +} + +#[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 { + Fruit, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::Integer.def(), + Self::Name => ColumnType::Text.def().null(), + Self::Price => ColumnType::Double.def().null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::Fruit => Entity::has_many(super::fruit::Entity).into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Fruit.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::cake_filling::Relation::Filling.def() + } + fn via() -> Option { + Some(super::cake_filling::Relation::CakeWithDouble.def().rev()) + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/sea-orm-codegen/tests/expanded/cake_with_float.rs b/sea-orm-codegen/tests/expanded/cake_with_float.rs new file mode 100644 index 00000000..d5059be1 --- /dev/null +++ b/sea-orm-codegen/tests/expanded/cake_with_float.rs @@ -0,0 +1,80 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.1.0 + +use sea_orm::entity::prelude::*; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "cake_with_float" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] +pub struct Model { + pub id: i32, + pub name: Option , + pub price: Option , +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + Name, + Price, +} + +#[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 { + Fruit, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::Integer.def(), + Self::Name => ColumnType::Text.def().null(), + Self::Price => ColumnType::Float.def().null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::Fruit => Entity::has_many(super::fruit::Entity).into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Fruit.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::cake_filling::Relation::Filling.def() + } + fn via() -> Option { + Some(super::cake_filling::Relation::CakeWithFloat.def().rev()) + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/sea-orm-codegen/tests/expanded/filling.rs b/sea-orm-codegen/tests/expanded/filling.rs index 76764ecf..22035244 100644 --- a/sea-orm-codegen/tests/expanded/filling.rs +++ b/sea-orm-codegen/tests/expanded/filling.rs @@ -11,7 +11,7 @@ impl EntityName for Entity { } } -#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq)] pub struct Model { pub id: i32, pub name: String, diff --git a/sea-orm-codegen/tests/expanded/fruit.rs b/sea-orm-codegen/tests/expanded/fruit.rs index 12919021..df1618ca 100644 --- a/sea-orm-codegen/tests/expanded/fruit.rs +++ b/sea-orm-codegen/tests/expanded/fruit.rs @@ -11,7 +11,7 @@ impl EntityName for Entity { } } -#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq)] pub struct Model { pub id: i32, pub name: String, diff --git a/sea-orm-codegen/tests/expanded/rust_keyword.rs b/sea-orm-codegen/tests/expanded/rust_keyword.rs index 1e96f791..8cdec4d8 100644 --- a/sea-orm-codegen/tests/expanded/rust_keyword.rs +++ b/sea-orm-codegen/tests/expanded/rust_keyword.rs @@ -11,7 +11,7 @@ impl EntityName for Entity { } } -#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq)] pub struct Model { pub id: i32, pub testing: i8, diff --git a/sea-orm-codegen/tests/expanded/vendor.rs b/sea-orm-codegen/tests/expanded/vendor.rs index ab4ae39a..91cbbd47 100644 --- a/sea-orm-codegen/tests/expanded/vendor.rs +++ b/sea-orm-codegen/tests/expanded/vendor.rs @@ -11,7 +11,7 @@ impl EntityName for Entity { } } -#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq)] pub struct Model { pub id: i32, pub name: String, diff --git a/sea-orm-codegen/tests/expanded_with_schema_name/cake.rs b/sea-orm-codegen/tests/expanded_with_schema_name/cake.rs index d37c2b08..72bdb0b1 100644 --- a/sea-orm-codegen/tests/expanded_with_schema_name/cake.rs +++ b/sea-orm-codegen/tests/expanded_with_schema_name/cake.rs @@ -15,7 +15,7 @@ impl EntityName for Entity { } } -#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq)] pub struct Model { pub id: i32, pub name: Option , diff --git a/sea-orm-codegen/tests/expanded_with_schema_name/cake_filling.rs b/sea-orm-codegen/tests/expanded_with_schema_name/cake_filling.rs index cde112e7..0113751f 100644 --- a/sea-orm-codegen/tests/expanded_with_schema_name/cake_filling.rs +++ b/sea-orm-codegen/tests/expanded_with_schema_name/cake_filling.rs @@ -15,7 +15,7 @@ impl EntityName for Entity { } } -#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq)] pub struct Model { pub cake_id: i32, pub filling_id: i32, diff --git a/sea-orm-codegen/tests/expanded_with_schema_name/cake_with_double.rs b/sea-orm-codegen/tests/expanded_with_schema_name/cake_with_double.rs new file mode 100644 index 00000000..0956e3e5 --- /dev/null +++ b/sea-orm-codegen/tests/expanded_with_schema_name/cake_with_double.rs @@ -0,0 +1,84 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.1.0 + +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 { + "cake_with_double" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] +pub struct Model { + pub id: i32, + pub name: Option , + pub price: Option , +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + Name, + Price, +} + +#[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 { + Fruit, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::Integer.def(), + Self::Name => ColumnType::Text.def().null(), + Self::Price => ColumnType::Double.def().null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::Fruit => Entity::has_many(super::fruit::Entity).into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Fruit.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::cake_filling::Relation::Filling.def() + } + fn via() -> Option { + Some(super::cake_filling::Relation::CakeWithDouble.def().rev()) + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/sea-orm-codegen/tests/expanded_with_schema_name/cake_with_float.rs b/sea-orm-codegen/tests/expanded_with_schema_name/cake_with_float.rs new file mode 100644 index 00000000..b3256ca2 --- /dev/null +++ b/sea-orm-codegen/tests/expanded_with_schema_name/cake_with_float.rs @@ -0,0 +1,84 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.1.0 + +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 { + "cake_with_float" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] +pub struct Model { + pub id: i32, + pub name: Option , + pub price: Option , +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + Name, + Price, +} + +#[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 { + Fruit, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::Integer.def(), + Self::Name => ColumnType::Text.def().null(), + Self::Price => ColumnType::Float.def().null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::Fruit => Entity::has_many(super::fruit::Entity).into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Fruit.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::cake_filling::Relation::Filling.def() + } + fn via() -> Option { + Some(super::cake_filling::Relation::CakeWithFloat.def().rev()) + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/sea-orm-codegen/tests/expanded_with_schema_name/filling.rs b/sea-orm-codegen/tests/expanded_with_schema_name/filling.rs index eb9005fb..918fd1bf 100644 --- a/sea-orm-codegen/tests/expanded_with_schema_name/filling.rs +++ b/sea-orm-codegen/tests/expanded_with_schema_name/filling.rs @@ -15,7 +15,7 @@ impl EntityName for Entity { } } -#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq)] pub struct Model { pub id: i32, pub name: String, diff --git a/sea-orm-codegen/tests/expanded_with_schema_name/fruit.rs b/sea-orm-codegen/tests/expanded_with_schema_name/fruit.rs index 2b554f6e..e2268ba6 100644 --- a/sea-orm-codegen/tests/expanded_with_schema_name/fruit.rs +++ b/sea-orm-codegen/tests/expanded_with_schema_name/fruit.rs @@ -15,7 +15,7 @@ impl EntityName for Entity { } } -#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq)] pub struct Model { pub id: i32, pub name: String, diff --git a/sea-orm-codegen/tests/expanded_with_schema_name/rust_keyword.rs b/sea-orm-codegen/tests/expanded_with_schema_name/rust_keyword.rs index faa8310f..b402bdac 100644 --- a/sea-orm-codegen/tests/expanded_with_schema_name/rust_keyword.rs +++ b/sea-orm-codegen/tests/expanded_with_schema_name/rust_keyword.rs @@ -15,7 +15,7 @@ impl EntityName for Entity { } } -#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq)] pub struct Model { pub id: i32, pub testing: i8, diff --git a/sea-orm-codegen/tests/expanded_with_schema_name/vendor.rs b/sea-orm-codegen/tests/expanded_with_schema_name/vendor.rs index fd3be27e..1ad920ab 100644 --- a/sea-orm-codegen/tests/expanded_with_schema_name/vendor.rs +++ b/sea-orm-codegen/tests/expanded_with_schema_name/vendor.rs @@ -15,7 +15,7 @@ impl EntityName for Entity { } } -#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq)] pub struct Model { pub id: i32, pub name: String, diff --git a/sea-orm-codegen/tests/expanded_with_serde/cake_both.rs b/sea-orm-codegen/tests/expanded_with_serde/cake_both.rs index 88821135..924887b4 100644 --- a/sea-orm-codegen/tests/expanded_with_serde/cake_both.rs +++ b/sea-orm-codegen/tests/expanded_with_serde/cake_both.rs @@ -12,7 +12,7 @@ impl EntityName for Entity { } } -#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] pub struct Model { pub id: i32, pub name: Option , diff --git a/sea-orm-codegen/tests/expanded_with_serde/cake_deserialize.rs b/sea-orm-codegen/tests/expanded_with_serde/cake_deserialize.rs index 068f17da..88a7c3a9 100644 --- a/sea-orm-codegen/tests/expanded_with_serde/cake_deserialize.rs +++ b/sea-orm-codegen/tests/expanded_with_serde/cake_deserialize.rs @@ -12,7 +12,7 @@ impl EntityName for Entity { } } -#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Deserialize)] +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Deserialize)] pub struct Model { pub id: i32, pub name: Option , diff --git a/sea-orm-codegen/tests/expanded_with_serde/cake_none.rs b/sea-orm-codegen/tests/expanded_with_serde/cake_none.rs index d0a1299a..a540fad1 100644 --- a/sea-orm-codegen/tests/expanded_with_serde/cake_none.rs +++ b/sea-orm-codegen/tests/expanded_with_serde/cake_none.rs @@ -11,7 +11,7 @@ impl EntityName for Entity { } } -#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)] +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq)] pub struct Model { pub id: i32, pub name: Option , diff --git a/sea-orm-codegen/tests/expanded_with_serde/cake_serialize.rs b/sea-orm-codegen/tests/expanded_with_serde/cake_serialize.rs index 30313fa1..72a17d58 100644 --- a/sea-orm-codegen/tests/expanded_with_serde/cake_serialize.rs +++ b/sea-orm-codegen/tests/expanded_with_serde/cake_serialize.rs @@ -12,7 +12,7 @@ impl EntityName for Entity { } } -#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Serialize)] +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize)] pub struct Model { pub id: i32, pub name: Option ,