pub struct ColumnSchema {
pub name: String,
pub ty: DataType,
pub nullable: bool,
pub default: Option<Value>,
pub runtime_default: Option<String>,
pub auto_increment: bool,
}Fields§
§name: String§ty: DataType§nullable: bool§default: Option<Value>Optional DEFAULT value, frozen at CREATE TABLE time. None
means “no default” (so omitted columns become NULL, or error
out when the column is NOT NULL). Literal defaults take this
path.
runtime_default: Option<String>v7.9.21 — for DEFAULT expressions that need INSERT-time
evaluation (e.g. DEFAULT now(), DEFAULT CURRENT_TIMESTAMP),
the Display form of the expression. The engine re-parses
it on each INSERT default-fill, evaluates against an empty
row context, and coerces to the column type. mailrs G4.
Persisted in catalog FILE_VERSION 15+; older catalogs
deserialise with None.
auto_increment: boolMySQL-style AUTO_INCREMENT. When set, an INSERT that leaves
this column unbound (or sets it to NULL) gets the next integer
computed from the column’s current max + 1.
Implementations§
Source§impl ColumnSchema
impl ColumnSchema
pub fn new( name: impl Into<String>, ty: DataType, nullable: bool, ) -> ColumnSchema
Sourcepub fn with_default(self, default: Value) -> ColumnSchema
pub fn with_default(self, default: Value) -> ColumnSchema
Builder-style helper to attach a default value to an otherwise
plain column schema. Used by the engine when CREATE TABLE
specifies column TYPE DEFAULT <expr>.
Sourcepub fn with_runtime_default(self, expr: impl Into<String>) -> ColumnSchema
pub fn with_runtime_default(self, expr: impl Into<String>) -> ColumnSchema
v7.9.21 — builder for runtime-evaluated defaults
(DEFAULT now(), DEFAULT CURRENT_TIMESTAMP, …).
expr is the Expr’s Display form, re-parsed by the
engine at each INSERT.
Sourcepub const fn with_auto_increment(self) -> ColumnSchema
pub const fn with_auto_increment(self) -> ColumnSchema
Builder-style helper to mark a column as AUTO_INCREMENT.
Trait Implementations§
Source§impl Clone for ColumnSchema
impl Clone for ColumnSchema
Source§fn clone(&self) -> ColumnSchema
fn clone(&self) -> ColumnSchema
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ColumnSchema
impl Debug for ColumnSchema
Source§impl PartialEq for ColumnSchema
impl PartialEq for ColumnSchema
Source§fn eq(&self, other: &ColumnSchema) -> bool
fn eq(&self, other: &ColumnSchema) -> bool
self and other values to be equal, and is used by ==.