Skip to main content

ColumnSchema

Struct ColumnSchema 

Source
pub struct ColumnSchema {
Show 13 fields pub name: String, pub ty: DataType, pub nullable: bool, pub default: Option<Value>, pub runtime_default: Option<String>, pub auto_increment: bool, pub user_enum_type: Option<String>, pub user_domain_type: Option<String>, pub on_update_runtime: Option<String>, pub collation: Collation, pub is_unsigned: bool, pub inline_enum_variants: Option<Vec<String>>, pub inline_set_variants: Option<Vec<String>>,
}

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: bool

MySQL-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.

§user_enum_type: Option<String>

v7.17.0 Phase 1.4 — when the column is bound to a user- defined ENUM type (the parser saw an unknown type ident and the engine resolved it against catalog.enum_types), this carries the enum name so INSERT/UPDATE can validate the cell value against the enum’s labels. ty is DataType::Text in that case. Persisted in catalog FILE_VERSION 29+; older catalogs deserialise with None.

§user_domain_type: Option<String>

v7.17.0 Phase 1.5 — when the column is bound to a user- defined DOMAIN (the parser saw an unknown type ident and the engine resolved it against catalog.domain_types), this carries the domain name. ty is the domain’s base type; INSERT/UPDATE re-evaluates the domain’s CHECK list

  • NOT NULL against the cell value. Persisted in catalog FILE_VERSION 30+; older catalogs deserialise with None.
§on_update_runtime: Option<String>

v7.17.0 Phase 2.1 — MySQL ON UPDATE CURRENT_TIMESTAMP column attribute. When Some(expr_src), an UPDATE that does NOT bind this column overrides the new value with the engine-evaluated expression (always now() in v7.17.0). Stored as Display-form source so storage stays free of spg-sql; the engine re-parses at UPDATE time. Persisted in catalog FILE_VERSION 32+; older catalogs deserialise with None — preserves the existing “silent ignore” behaviour for snapshots written before the upgrade.

§collation: Collation

v7.17.0 Phase 2.5 — text collation. Pre-2.5 SPG accepted COLLATE <name> clauses but discarded the name, so a column declared COLLATE "case_insensitive" (or any MySQL _ci collation) still compared byte-wise — a Tier-S silent failure where WHERE name = 'foo' never matched stored 'Foo'. This carries the parser-derived classification so the engine’s WHERE evaluator can route text equality through a case-aware compare. Binary (the default) preserves the prior byte-wise behaviour. Only CaseInsensitive lands in the catalog appendix — Binary columns stay implicit, keeping snapshots compact. Persisted in catalog FILE_VERSION 34+; older catalogs deserialise every column as Binary.

§is_unsigned: bool

v7.17.0 Phase 4.4 — MySQL UNSIGNED modifier flag. Drives engine-side INSERT / UPDATE range enforcement (rejects negative values on UNSIGNED int columns). Pre-4.4 the parser consumed and discarded the keyword silently, so every UNSIGNED column quietly accepted negatives — a Tier-A correctness drift. Sparse: only UNSIGNED columns land in the catalog appendix; the default false keeps snapshots compact for the common signed-int path. Persisted in catalog FILE_VERSION 35+; older catalogs deserialise every column as is_unsigned = false.

§inline_enum_variants: Option<Vec<String>>

v7.17.0 Phase 3.P0-36 — MySQL inline ENUM('a','b','c') value list. Distinct from user_enum_type (which points to a separately CREATE TYPE’d PG enum); this carries the column-local list MySQL DDL declares inline. When Some, ty is DataType::Text and INSERT/UPDATE validates the cell value against this list. Variant ORDER is preserved (MySQL uses it for ORDER BY col). Sparse: only ENUM columns land in the catalog appendix. Persisted in catalog FILE_VERSION 41+; older catalogs deserialise with None — preserves silent-drop behaviour for snapshots written before P0-36.

§inline_set_variants: Option<Vec<String>>

v7.17.0 Phase 3.P0-37 — MySQL inline SET('a','b','c') variant list. Storage is TEXT (canonical comma-joined in definition order, de-duplicated). INSERT/UPDATE validates every comma-separated token against this list. Sparse: only SET columns land in the catalog appendix. Persisted in catalog FILE_VERSION 42+; older catalogs deserialise with None.

Implementations§

Source§

impl ColumnSchema

Source

pub fn new( name: impl Into<String>, ty: DataType, nullable: bool, ) -> ColumnSchema

Source

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>.

Source

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.

Source

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

Source§

fn clone(&self) -> ColumnSchema

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ColumnSchema

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl PartialEq for ColumnSchema

Source§

fn eq(&self, other: &ColumnSchema) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for ColumnSchema

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.