cargo fmt

This commit is contained in:
Billy Chan 2022-03-25 15:25:49 +08:00
parent 5a473ba754
commit 6091629adb
No known key found for this signature in database
GPG Key ID: A2D690CAC7DF3CC7
5 changed files with 30 additions and 32 deletions

View File

@ -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

View File

@ -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 {
@ -87,8 +87,11 @@ where
vec
}
pub(crate) fn create_index_from_entity<E>(entity: E, _backend: DbBackend) -> Vec<IndexCreateStatement>
where
pub(crate) fn create_index_from_entity<E>(
entity: E,
_backend: DbBackend,
) -> Vec<IndexCreateStatement>
where
E: EntityTrait,
{
let mut vec = Vec::new();
@ -111,7 +114,6 @@ pub(crate) fn create_index_from_entity<E>(entity: E, _backend: DbBackend) -> Vec
vec
}
pub(crate) fn create_table_from_entity<E>(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()
}
}

View File

@ -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 {}

View File

@ -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;