pub struct Column {
pub table: Cow<'static, str>,
pub name: Cow<'static, str>,
pub sql_type: Cow<'static, str>,
pub not_null: bool,
pub autoincrement: Option<bool>,
pub primary_key: Option<bool>,
pub unique: Option<bool>,
pub default: Option<Cow<'static, str>>,
pub generated: Option<Generated>,
pub ordinal_position: Option<i32>,
}Expand description
Runtime column entity for serde serialization.
Fields§
§table: Cow<'static, str>Parent table name
name: Cow<'static, str>Column name
sql_type: Cow<'static, str>SQL type (e.g., “INTEGER”, “TEXT”, “REAL”, “BLOB”)
not_null: boolIs this column NOT NULL?
autoincrement: Option<bool>Is this column AUTOINCREMENT?
primary_key: Option<bool>Is this column a PRIMARY KEY?
unique: Option<bool>Is this column UNIQUE?
default: Option<Cow<'static, str>>Default value as string
generated: Option<Generated>Generated column configuration
ordinal_position: Option<i32>Ordinal position within the table (cid, 0-based).
This is primarily populated by introspection and used for stable codegen ordering.
Implementations§
Source§impl Column
impl Column
Sourcepub fn new(
table: impl Into<Cow<'static, str>>,
name: impl Into<Cow<'static, str>>,
sql_type: impl Into<Cow<'static, str>>,
) -> Self
pub fn new( table: impl Into<Cow<'static, str>>, name: impl Into<Cow<'static, str>>, sql_type: impl Into<Cow<'static, str>>, ) -> Self
Create a new column (runtime)
Sourcepub fn autoincrement(self) -> Self
pub fn autoincrement(self) -> Self
Set AUTOINCREMENT
Sourcepub fn default_value(self, value: impl Into<Cow<'static, str>>) -> Self
pub fn default_value(self, value: impl Into<Cow<'static, str>>) -> Self
Set default value
Sourcepub fn is_primary_key(&self) -> bool
pub fn is_primary_key(&self) -> bool
Check if this is a primary key column
Sourcepub fn is_autoincrement(&self) -> bool
pub fn is_autoincrement(&self) -> bool
Check if this is an autoincrement column
Source§impl Column
impl Column
Sourcepub fn to_column_sql(&self, inline_pk: bool, inline_unique: bool) -> String
pub fn to_column_sql(&self, inline_pk: bool, inline_unique: bool) -> String
Generate the column definition SQL (without leading/trailing punctuation)
Sourcepub fn add_column_sql(&self) -> String
pub fn add_column_sql(&self) -> String
Generate ADD COLUMN SQL
Sourcepub fn drop_column_sql(&self) -> String
pub fn drop_column_sql(&self) -> String
Generate DROP COLUMN SQL
Trait Implementations§
impl Eq for Column
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 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