pub struct Column {
pub name: String,
pub column_type: ColumnType,
pub nullable: bool,
pub default: Option<String>,
pub unique: bool,
pub references: Option<ForeignKey>,
pub check: Option<String>,
}Expand description
Table column
Fields§
§name: String§column_type: ColumnType§nullable: bool§default: Option<String>§unique: bool§references: Option<ForeignKey>§check: Option<String>Implementations§
Source§impl Column
impl Column
Sourcepub fn new(name: impl Into<String>, column_type: ColumnType) -> Self
pub fn new(name: impl Into<String>, column_type: ColumnType) -> Self
Create a new column
Sourcepub fn references(self, fk: ForeignKey) -> Self
pub fn references(self, fk: ForeignKey) -> Self
Set the foreign key reference
Sourcepub fn set_not_null(&mut self) -> &mut Self
pub fn set_not_null(&mut self) -> &mut Self
Set the column as not nullable (in-place)
Sourcepub fn set_nullable(&mut self) -> &mut Self
pub fn set_nullable(&mut self) -> &mut Self
Set the column as nullable (in-place)
Sourcepub fn set_unique(&mut self) -> &mut Self
pub fn set_unique(&mut self) -> &mut Self
Set the column as unique (in-place)
Sourcepub fn set_default(&mut self, default: impl Into<String>) -> &mut Self
pub fn set_default(&mut self, default: impl Into<String>) -> &mut Self
Set the default value (in-place)
Sourcepub fn set_references(&mut self, fk: ForeignKey) -> &mut Self
pub fn set_references(&mut self, fk: ForeignKey) -> &mut Self
Set the foreign key reference (in-place)
Sourcepub fn generate_column_definition(&self) -> String
pub fn generate_column_definition(&self) -> String
Generate column definition for DDL (alias for to_sql)
Trait Implementations§
impl StructuralPartialEq for Column
Auto Trait Implementations§
impl Freeze for Column
impl RefUnwindSafe for Column
impl Send for Column
impl Sync for Column
impl Unpin for Column
impl UnsafeUnpin for Column
impl UnwindSafe for Column
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more