Rename entity_to_table_create_statement
This commit is contained in:
parent
4a701d5e2d
commit
b100e32ffd
@ -6,7 +6,6 @@ mod model;
|
||||
pub mod prelude;
|
||||
mod primary_key;
|
||||
mod relation;
|
||||
mod schema;
|
||||
|
||||
pub use active_model::*;
|
||||
pub use base_entity::*;
|
||||
@ -16,4 +15,3 @@ pub use model::*;
|
||||
// pub use prelude::*;
|
||||
pub use primary_key::*;
|
||||
pub use relation::*;
|
||||
pub use schema::*;
|
||||
|
@ -214,6 +214,7 @@ pub mod entity;
|
||||
pub mod error;
|
||||
mod executor;
|
||||
pub mod query;
|
||||
pub mod schema;
|
||||
#[doc(hidden)]
|
||||
pub mod tests_cfg;
|
||||
mod util;
|
||||
@ -224,6 +225,7 @@ pub use entity::*;
|
||||
pub use error::*;
|
||||
pub use executor::*;
|
||||
pub use query::*;
|
||||
pub use schema::*;
|
||||
|
||||
pub use sea_orm_macros::{
|
||||
DeriveActiveModel, DeriveActiveModelBehavior, DeriveColumn, DeriveCustomColumn, DeriveEntity,
|
||||
|
@ -4,7 +4,7 @@ use crate::{
|
||||
};
|
||||
use sea_query::{ColumnDef, ForeignKeyCreateStatement, Iden, Index, TableCreateStatement};
|
||||
|
||||
pub fn entity_to_table_create_statement<E>(entity: E) -> TableCreateStatement
|
||||
pub fn create_table_from_entity<E>(entity: E) -> TableCreateStatement
|
||||
where
|
||||
E: EntityTrait,
|
||||
{
|
||||
@ -112,14 +112,14 @@ where
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{entity_to_table_create_statement, tests_cfg::*};
|
||||
use crate::{create_table_from_entity, tests_cfg::*};
|
||||
use pretty_assertions::assert_eq;
|
||||
use sea_query::*;
|
||||
|
||||
#[test]
|
||||
fn test_entity_to_table_create_statement() {
|
||||
fn test_create_table_from_entity() {
|
||||
assert_eq!(
|
||||
entity_to_table_create_statement(CakeFillingPrice).to_string(MysqlQueryBuilder),
|
||||
create_table_from_entity(CakeFillingPrice).to_string(MysqlQueryBuilder),
|
||||
Table::create()
|
||||
.table(CakeFillingPrice)
|
||||
.if_not_exists()
|
3
src/schema/mod.rs
Normal file
3
src/schema/mod.rs
Normal file
@ -0,0 +1,3 @@
|
||||
mod entity;
|
||||
|
||||
pub use entity::*;
|
@ -1,8 +1,6 @@
|
||||
pub use super::super::bakery_chain::*;
|
||||
use pretty_assertions::assert_eq;
|
||||
use sea_orm::{
|
||||
entity_to_table_create_statement, error::*, sea_query, DbConn, EntityTrait, ExecResult,
|
||||
};
|
||||
use sea_orm::{create_table_from_entity, error::*, sea_query, DbConn, EntityTrait, ExecResult};
|
||||
use sea_query::{ColumnDef, ForeignKey, ForeignKeyAction, Index, Table, TableCreateStatement};
|
||||
|
||||
async fn create_table<E>(
|
||||
@ -15,10 +13,7 @@ where
|
||||
{
|
||||
let builder = db.get_database_backend();
|
||||
let stmt = builder.build(stmt);
|
||||
assert_eq!(
|
||||
builder.build(&entity_to_table_create_statement(entity)),
|
||||
stmt
|
||||
);
|
||||
assert_eq!(builder.build(&create_table_from_entity(entity)), stmt);
|
||||
db.execute(stmt).await
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user