Skip to main content

ColumnDef

Struct ColumnDef 

Source
pub struct ColumnDef {
Show 14 fields pub name: String, pub ty: ColumnTypeName, pub nullable: bool, pub default: Option<Expr>, pub auto_increment: bool, pub is_primary_key: bool, pub is_unique: bool, pub check: Option<Expr>, pub user_type_ref: Option<String>, pub on_update_runtime: Option<Expr>, 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: ColumnTypeName§nullable: bool§default: Option<Expr>

DEFAULT <expr> literal supplied at CREATE TABLE. Engine evaluates this once (with an empty row) and caches the resulting Value on the column schema.

§auto_increment: bool

MySQL-style AUTO_INCREMENT — the engine maintains a counter per such column and fills the slot when INSERT leaves it unbound (omitted from a column-list INSERT or explicitly NULL).

§is_primary_key: bool

v7.9.13 — inline PRIMARY KEY column constraint. mailrs migration follow-up F1. Implies NOT NULL. Engine creates an implicit BTree index named <table>_pkey over this column at CREATE TABLE time, satisfying the parent-side index requirement for any FOREIGN KEY pointing at it.

§is_unique: bool

v7.13.0 — inline UNIQUE column constraint (mailrs round-5 G2). The CREATE TABLE handler folds this into a single-column TableConstraint::Unique so the engine path stays uniform with table-level UNIQUE.

§check: Option<Expr>

v7.13.0 — inline CHECK (<expr>) column constraint (mailrs round-5 G3). Stored alongside the column so the CREATE TABLE handler can fold these into table-level CHECK constraints. Multiple inline CHECKs on the same column are concatenated with AND at the table level.

§user_type_ref: Option<String>

v7.17.0 Phase 1.4 — user-defined type reference. When the parser sees an unknown column-type ident (anything not in the built-in parse_column_type_name table), it sets ty = ColumnTypeName::Text and records the original name here. The engine resolves at CREATE TABLE time: if a catalog enum/domain with this name exists, the column is bound to it (label-checked on INSERT for enums; CHECK- constrained for domains); otherwise the CREATE TABLE errors with “unknown type”.

§on_update_runtime: Option<Expr>

v7.17.0 Phase 2.1 — MySQL-style ON UPDATE CURRENT_TIMESTAMP column attribute. When set, an UPDATE that does NOT explicitly bind this column overrides the new value with now() (engine clock). Pre-v7.17 SPG silently accepted the syntax and never fired the override — updated_at columns from mysqldump stayed pinned at their initial DEFAULT forever, an audit Tier-S silent-failure. Generalised as a stored expression source so future shapes (ON UPDATE CURRENT_TIMESTAMP(6), ON UPDATE LOCALTIMESTAMP) reuse the same field; v7.17 only accepts CURRENT_TIMESTAMP.

§collation: Collation

v7.17.0 Phase 2.5 — text collation derived from the post-fix COLLATE <name> clause (and / or the table-level COLLATE=<name> for MySQL dumps that don’t repeat it per column). Pre-2.5 SPG accepted the clause and discarded the name, leaving every column byte-compared — a Tier-S silent failure when the customer expected _ci / case_insensitive semantics. Parser normalises the raw collation name into the variants in Collation. Default Binary preserves the legacy compare path.

§is_unsigned: bool

v7.17.0 Phase 4.4 — MySQL UNSIGNED modifier flag. Pre- 4.4 SPG accepted and discarded the keyword, leaving negative values silently accepted on a column the customer declared INT UNSIGNED NOT NULL. Now: the engine rejects negative INSERT / UPDATE values on UNSIGNED int columns. SPG widening to u64-shaped storage is out of v7.17 scope; the upper bound remains the signed-type max (i64::MAX for BIGINT UNSIGNED), which still strictly exceeds what every mailrs / Rails app actually uses.

§inline_enum_variants: Option<Vec<String>>

v7.17.0 Phase 3.P0-36 — MySQL inline ENUM('a','b','c') value list captured at parse time. When Some, the parser recognised ENUM(...) in the type slot; the engine validates INSERT cells against this list at column_def_to_schema time and persists the variants on ColumnSchema.inline_enum_variants. None for all non-ENUM columns.

§inline_set_variants: Option<Vec<String>>

v7.17.0 Phase 3.P0-37 — MySQL inline SET('a','b','c') value list. Distinct from ENUM (subset semantics rather than pick-one). None for all non-SET columns.

Trait Implementations§

Source§

impl Clone for ColumnDef

Source§

fn clone(&self) -> ColumnDef

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 ColumnDef

Source§

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

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

impl Display for ColumnDef

Source§

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

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

impl PartialEq for ColumnDef

Source§

fn eq(&self, other: &ColumnDef) -> 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 ColumnDef

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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.