pub struct SchemaColumn {Show 14 fields
pub id: usize,
pub name: String,
pub data_type: DataType,
pub external_type: Option<ExternalTypeRef>,
pub external_type_name: Option<String>,
pub nullable: bool,
pub primary_key: bool,
pub auto_increment: bool,
pub default_expr: Option<String>,
pub default_value: Option<Value>,
pub check_expr: Option<String>,
pub vector_dimensions: u16,
pub decimal_precision: u8,
pub decimal_scale: u8,
/* private fields */
}Expand description
A column definition in a table schema
Fields§
§id: usizeUnique identifier for the column (0-based index)
name: StringColumn name
data_type: DataTypeData type of the column
external_type: Option<ExternalTypeRef>Stable external type identity. Built-in columns keep this empty.
external_type_name: Option<String>Schema-qualified SQL type name used by introspection and dump output.
nullable: boolWhether the column can contain NULL values
primary_key: boolWhether this column is part of the primary key
auto_increment: boolWhether this column auto-increments (generates sequential IDs for NULL values)
default_expr: Option<String>Default value expression as a string (to be parsed and evaluated during INSERT)
default_value: Option<Value>Pre-computed default value for schema evolution (used when adding column to existing rows)
check_expr: Option<String>CHECK constraint expression as a string (to be parsed and evaluated during INSERT)
vector_dimensions: u16Number of dimensions for VECTOR columns (0 = not a vector column)
decimal_precision: u8Declared precision for DECIMAL columns (0 = unconstrained DECIMAL).
decimal_scale: u8Declared scale for DECIMAL columns. This is zero when precision is zero.
Implementations§
Source§impl SchemaColumn
impl SchemaColumn
Sourcepub fn new(
id: usize,
name: impl Into<String>,
data_type: DataType,
nullable: bool,
primary_key: bool,
) -> Self
pub fn new( id: usize, name: impl Into<String>, data_type: DataType, nullable: bool, primary_key: bool, ) -> Self
Create a new column definition
Sourcepub fn with_vector_dimensions(self, dims: u16) -> Self
pub fn with_vector_dimensions(self, dims: u16) -> Self
Set vector dimensions (for VECTOR columns)
Sourcepub fn with_decimal_parameters(self, precision: u8, scale: u8) -> Self
pub fn with_decimal_parameters(self, precision: u8, scale: u8) -> Self
Set exact DECIMAL(p,s) column parameters. A precision of zero denotes the unparameterized DECIMAL domain and requires scale zero.
pub fn with_external_type( self, type_ref: ExternalTypeRef, sql_name: impl Into<String>, ) -> Self
pub const fn logical_type(&self) -> LogicalTypeRef
Sourcepub fn formatted_data_type(&self) -> String
pub fn formatted_data_type(&self) -> String
Render the complete declared SQL type, including durable modifiers.
Sourcepub fn has_same_declared_type(&self, other: &Self) -> bool
pub fn has_same_declared_type(&self, other: &Self) -> bool
Exact schema-level type identity used by references and descriptors.
Sourcepub fn validate_declared_value(&self, value: &Value) -> Result<()>
pub fn validate_declared_value(&self, value: &Value) -> Result<()>
Validate value-level modifiers that are not represented by DataType.
The value is not rewritten: exact decimal payload bytes remain intact.
Sourcepub fn with_constraints(
id: usize,
name: impl Into<String>,
data_type: DataType,
nullable: bool,
primary_key: bool,
auto_increment: bool,
default_expr: Option<String>,
check_expr: Option<String>,
) -> Self
pub fn with_constraints( id: usize, name: impl Into<String>, data_type: DataType, nullable: bool, primary_key: bool, auto_increment: bool, default_expr: Option<String>, check_expr: Option<String>, ) -> Self
Create a new column definition with all options
Sourcepub fn with_default_value(
id: usize,
name: impl Into<String>,
data_type: DataType,
nullable: bool,
primary_key: bool,
auto_increment: bool,
default_expr: Option<String>,
default_value: Option<Value>,
check_expr: Option<String>,
) -> Self
pub fn with_default_value( id: usize, name: impl Into<String>, data_type: DataType, nullable: bool, primary_key: bool, auto_increment: bool, default_expr: Option<String>, default_value: Option<Value>, check_expr: Option<String>, ) -> Self
Create a new column definition with pre-computed default value
Sourcepub fn simple(id: usize, name: impl Into<String>, data_type: DataType) -> Self
pub fn simple(id: usize, name: impl Into<String>, data_type: DataType) -> Self
Create a simple non-nullable, non-primary-key column
Trait Implementations§
Source§impl Clone for SchemaColumn
impl Clone for SchemaColumn
Source§fn clone(&self) -> SchemaColumn
fn clone(&self) -> SchemaColumn
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more