diff --git a/sea-orm-codegen/src/entity/writer.rs b/sea-orm-codegen/src/entity/writer.rs index a5c4af0d..88d72ef3 100644 --- a/sea-orm-codegen/src/entity/writer.rs +++ b/sea-orm-codegen/src/entity/writer.rs @@ -150,10 +150,7 @@ impl EntityWriter { pub fn write_sea_orm_active_enums(&self, with_serde: &WithSerde) -> OutputFile { let mut lines = Vec::new(); Self::write_doc_comment(&mut lines); - Self::write( - &mut lines, - vec![Self::gen_import(with_serde)], - ); + Self::write(&mut lines, vec![Self::gen_import(with_serde)]); lines.push("".to_owned()); let code_blocks = self .enums diff --git a/src/lib.rs b/src/lib.rs index 892b397a..dde6ae0c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -254,9 +254,9 @@ //! 1. [Architecture](https://github.com/SeaQL/sea-orm/tree/master/ARCHITECTURE.md) //! 1. [Release Model](https://www.sea-ql.org/SeaORM/blog/2021-08-30-release-model) //! 1. [Change Log](https://github.com/SeaQL/sea-orm/tree/master/CHANGELOG.md) -//! +//! //! ## Who's using SeaORM? -//! +//! //! [Built with SeaORM](https://github.com/SeaQL/sea-orm/blob/master/COMMUNITY.md#built-with-seaorm) //! //! ## License diff --git a/src/schema/entity.rs b/src/schema/entity.rs index 5cc3e728..c09862be 100644 --- a/src/schema/entity.rs +++ b/src/schema/entity.rs @@ -4,8 +4,8 @@ use crate::{ }; use sea_query::{ extension::postgres::{Type, TypeCreateStatement}, - Alias, ColumnDef, ForeignKeyCreateStatement, Iden, Index, TableCreateStatement, - IndexCreateStatement, + Alias, ColumnDef, ForeignKeyCreateStatement, Iden, Index, IndexCreateStatement, + TableCreateStatement, }; impl Schema { @@ -36,8 +36,8 @@ impl Schema { /// Creates the indexes from an Entity, returning an empty Vec if there are none /// to create. See [IndexCreateStatement] for more details pub fn create_index_from_entity(&self, entity: E) -> Vec - where - E: EntityTrait, + where + E: EntityTrait, { create_index_from_entity(entity, self.backend) } @@ -87,9 +87,12 @@ where vec } -pub(crate) fn create_index_from_entity(entity: E, _backend: DbBackend) -> Vec - where - E: EntityTrait, +pub(crate) fn create_index_from_entity( + entity: E, + _backend: DbBackend, +) -> Vec +where + E: EntityTrait, { let mut vec = Vec::new(); for column in E::Column::iter() { @@ -111,7 +114,6 @@ pub(crate) fn create_index_from_entity(entity: E, _backend: DbBackend) -> Vec vec } - pub(crate) fn create_table_from_entity(entity: E, backend: DbBackend) -> TableCreateStatement where E: EntityTrait, @@ -229,7 +231,11 @@ mod tests { let schema = Schema::new(builder); assert_eq!( builder.build(&schema.create_table_from_entity(CakeFillingPrice)), - builder.build(&get_cake_filling_price_stmt().table(CakeFillingPrice.table_ref()).to_owned()) + builder.build( + &get_cake_filling_price_stmt() + .table(CakeFillingPrice.table_ref()) + .to_owned() + ) ); } } @@ -271,7 +277,6 @@ mod tests { .to_owned() } - #[test] fn test_create_index_from_entity_table_ref() { for builder in [DbBackend::MySql, DbBackend::Postgres, DbBackend::Sqlite] { @@ -279,37 +284,32 @@ mod tests { assert_eq!( builder.build(&schema.create_table_from_entity(indexes::Entity)), - builder.build(&get_indexes_stmt().table(indexes::Entity.table_ref()).to_owned()) + builder.build( + &get_indexes_stmt() + .table(indexes::Entity.table_ref()) + .to_owned() + ) ); - let stmts = schema.create_index_from_entity(indexes::Entity); assert_eq!(stmts.len(), 2); - let idx: IndexCreateStatement = Index::create() .name("idx-indexes-index1_attr") .table(indexes::Entity) .col(indexes::Column::Index1Attr) .to_owned(); - assert_eq!( - builder.build(&stmts[0]), - builder.build(&idx) - ); + assert_eq!(builder.build(&stmts[0]), builder.build(&idx)); let idx: IndexCreateStatement = Index::create() .name("idx-indexes-index2_attr") .table(indexes::Entity) .col(indexes::Column::Index2Attr) .to_owned(); - assert_eq!( - builder.build(&stmts[1]), - builder.build(&idx) - ); + assert_eq!(builder.build(&stmts[1]), builder.build(&idx)); } } - fn get_indexes_stmt() -> TableCreateStatement { Table::create() .col( @@ -338,5 +338,4 @@ mod tests { ) .to_owned() } - } diff --git a/src/tests_cfg/indexes.rs b/src/tests_cfg/indexes.rs index 36738817..c823e31d 100644 --- a/src/tests_cfg/indexes.rs +++ b/src/tests_cfg/indexes.rs @@ -45,7 +45,7 @@ impl PrimaryKeyTrait for PrimaryKey { } #[derive(Copy, Clone, Debug, EnumIter)] -pub enum Relation { } +pub enum Relation {} impl ColumnTrait for Column { type EntityName = Entity; @@ -61,7 +61,9 @@ impl ColumnTrait for Column { } impl RelationTrait for Relation { - fn def(&self) -> RelationDef { panic!() } + fn def(&self) -> RelationDef { + panic!() + } } impl ActiveModelBehavior for ActiveModel {} diff --git a/src/tests_cfg/mod.rs b/src/tests_cfg/mod.rs index 008c4f6b..7f6178ef 100644 --- a/src/tests_cfg/mod.rs +++ b/src/tests_cfg/mod.rs @@ -7,9 +7,9 @@ pub mod cake_filling_price; pub mod entity_linked; pub mod filling; pub mod fruit; +pub mod indexes; pub mod rust_keyword; pub mod vendor; -pub mod indexes; pub use cake::Entity as Cake; pub use cake_expanded::Entity as CakeExpanded;