pub struct ColumnDef {
pub name: String,
pub col_type: ColumnType,
pub nullable: bool,
pub primary_key: bool,
pub auto_increment: bool,
pub default_value: Option<String>,
pub unique: bool,
}Expand description
列定义
Fields§
§name: String列名
col_type: ColumnType列类型
nullable: bool是否可空
primary_key: bool是否主键
auto_increment: bool是否自增
default_value: Option<String>默认值
unique: bool是否唯一
Implementations§
Source§impl ColumnDef
impl ColumnDef
Sourcepub fn new(name: impl Into<String>, col_type: ColumnType) -> Self
pub fn new(name: impl Into<String>, col_type: ColumnType) -> Self
创建新的列定义
Sourcepub fn primary_key(self) -> Self
pub fn primary_key(self) -> Self
设置为主键
Sourcepub fn auto_increment(self) -> Self
pub fn auto_increment(self) -> Self
设置为自增
Sourcepub fn to_sql_for(&self, db_type: DatabaseType) -> String
pub fn to_sql_for(&self, db_type: DatabaseType) -> String
生成指定数据库类型的建表 SQL 片段
Trait Implementations§
Source§impl<'de> Deserialize<'de> for ColumnDef
impl<'de> Deserialize<'de> for ColumnDef
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ColumnDef
impl RefUnwindSafe for ColumnDef
impl Send for ColumnDef
impl Sync for ColumnDef
impl Unpin for ColumnDef
impl UnsafeUnpin for ColumnDef
impl UnwindSafe for ColumnDef
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more