From 60fd9061bd0cb94bca05ba720ab9e27a6da82d9f Mon Sep 17 00:00:00 2001 From: Chris Tsang Date: Mon, 14 Jun 2021 21:00:44 +0800 Subject: [PATCH] ColumnDef TODO --- src/entity/column.rs | 12 ++++++++---- src/entity/primary_key.rs | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/entity/column.rs b/src/entity/column.rs index 52da7a2d..a5017126 100644 --- a/src/entity/column.rs +++ b/src/entity/column.rs @@ -2,6 +2,14 @@ use crate::{EntityName, IdenStatic, Iterable}; pub use sea_query::ColumnType; 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 { ( $op: ident ) => { fn $op(&self, v: V) -> SimpleExpr @@ -40,10 +48,6 @@ pub trait ColumnTrait: IdenStatic + Iterable { fn def(&self) -> ColumnType; - // we may add more: - // fn indexed(&self) -> bool; - // fn unique(&self) -> bool; - fn entity_name(&self) -> DynIden { SeaRc::new(Self::EntityName::default()) as DynIden } diff --git a/src/entity/primary_key.rs b/src/entity/primary_key.rs index 8023c5ee..81a28915 100644 --- a/src/entity/primary_key.rs +++ b/src/entity/primary_key.rs @@ -1,5 +1,6 @@ use super::{ColumnTrait, IdenStatic, Iterable}; +//LINT: composite primary key cannot auto increment pub trait PrimaryKeyTrait: IdenStatic + Iterable { fn auto_increment() -> bool; }