ColumnDef TODO

This commit is contained in:
Chris Tsang 2021-06-14 21:00:44 +08:00
parent 5c3bd08b99
commit 60fd9061bd
2 changed files with 9 additions and 4 deletions

View File

@ -2,6 +2,14 @@ use crate::{EntityName, IdenStatic, Iterable};
pub use sea_query::ColumnType; pub use sea_query::ColumnType;
use sea_query::{DynIden, Expr, SeaRc, SimpleExpr, Value}; use sea_query::{DynIden, Expr, SeaRc, SimpleExpr, Value};
// TODO: ColumnDef with builder API to replace sea_query::ColumnType in Entity def
pub struct ColumnDef {
pub(crate) col_type: ColumnType,
pub(crate) not_null: bool,
pub(crate) unique: bool,
pub(crate) indexed: bool,
}
macro_rules! bind_oper { macro_rules! bind_oper {
( $op: ident ) => { ( $op: ident ) => {
fn $op<V>(&self, v: V) -> SimpleExpr fn $op<V>(&self, v: V) -> SimpleExpr
@ -40,10 +48,6 @@ pub trait ColumnTrait: IdenStatic + Iterable {
fn def(&self) -> ColumnType; fn def(&self) -> ColumnType;
// we may add more:
// fn indexed(&self) -> bool;
// fn unique(&self) -> bool;
fn entity_name(&self) -> DynIden { fn entity_name(&self) -> DynIden {
SeaRc::new(Self::EntityName::default()) as DynIden SeaRc::new(Self::EntityName::default()) as DynIden
} }

View File

@ -1,5 +1,6 @@
use super::{ColumnTrait, IdenStatic, Iterable}; use super::{ColumnTrait, IdenStatic, Iterable};
//LINT: composite primary key cannot auto increment
pub trait PrimaryKeyTrait: IdenStatic + Iterable { pub trait PrimaryKeyTrait: IdenStatic + Iterable {
fn auto_increment() -> bool; fn auto_increment() -> bool;
} }