pub struct ColumnDef {
pub schema: &'static str,
pub table: &'static str,
pub name: &'static str,
pub sql_type: &'static str,
pub type_schema: Option<&'static str>,
pub not_null: bool,
pub default: Option<&'static str>,
pub generated: Option<GeneratedDef>,
pub identity: Option<IdentityDef>,
pub dimensions: Option<i32>,
pub collate: Option<&'static str>,
}Expand description
Const-friendly column definition for compile-time schema definitions.
Fields§
§schema: &'static strSchema name
table: &'static strParent table name
name: &'static strColumn name
sql_type: &'static strSQL type (e.g., “INTEGER”, “TEXT”, “VARCHAR”)
type_schema: Option<&'static str>Type schema (for custom types)
not_null: boolIs this column NOT NULL?
default: Option<&'static str>Default value as string (if any)
generated: Option<GeneratedDef>Generated column configuration
identity: Option<IdentityDef>Identity column configuration
dimensions: Option<i32>Array dimensions (for array types)
collate: Option<&'static str>Collation name (e.g. "en_US", "C", "POSIX", or any custom
CREATE COLLATION value). None means “use the database default
collation for this column type” and no COLLATE clause is emitted.
Implementations§
Source§impl ColumnDef
impl ColumnDef
Sourcepub const fn new(
schema: &'static str,
table: &'static str,
name: &'static str,
sql_type: &'static str,
) -> Self
pub const fn new( schema: &'static str, table: &'static str, name: &'static str, sql_type: &'static str, ) -> Self
Create a new column definition
Sourcepub const fn type_schema(self, schema: &'static str) -> Self
pub const fn type_schema(self, schema: &'static str) -> Self
Set type schema (for custom types)
Sourcepub const fn default_value(self, value: &'static str) -> Self
pub const fn default_value(self, value: &'static str) -> Self
Set default value
Sourcepub const fn generated_stored(self, expression: &'static str) -> Self
pub const fn generated_stored(self, expression: &'static str) -> Self
Set as generated stored column
Sourcepub const fn identity(self, identity: IdentityDef) -> Self
pub const fn identity(self, identity: IdentityDef) -> Self
Set as identity column
Sourcepub const fn dimensions(self, dims: i32) -> Self
pub const fn dimensions(self, dims: i32) -> Self
Set array dimensions
Sourcepub const fn collate(self, name: &'static str) -> Self
pub const fn collate(self, name: &'static str) -> Self
Set the collation for this column.
PostgreSQL treats COLLATE identifiers as quoted names — e.g.
COLLATE "en_US", COLLATE "C", COLLATE "POSIX". Pass the bare
name here; the DDL emitter wraps it in double quotes.
Sourcepub const fn into_column(self) -> Column
pub const fn into_column(self) -> Column
Convert to runtime Column type
Note: This method cannot be const because it needs to convert nested Option types (generated and identity) which require runtime method calls.