Skip to main content

ColumnDefinitionSyntax

Struct ColumnDefinitionSyntax 

Source
pub struct ColumnDefinitionSyntax {
Show 13 fields pub generated_column_shorthand: bool, pub column_conflict_resolution_clause: bool, pub typeless_column_definitions: bool, pub typeless_generated_columns: bool, pub joined_autoincrement_attribute: bool, pub inline_primary_key_ordering: bool, pub named_column_collate_constraint: bool, pub identity_columns: bool, pub compact_identity_columns: bool, pub default_expression_requires_parens: bool, pub column_default_requires_b_expr: bool, pub column_collation: bool, pub column_storage: bool,
}
Expand description

Dialect-owned CREATE TABLE column-definition syntax accepted by the parser.

The column-level decorations inside a CREATE TABLE definition — the attributes and restrictions that attach to a single column. Split out of the retired SchemaChangeSyntax at its 16-field line as the column-definition axis, distinct from the table-clause and constraint axes. Each flag is a grammar gate: when off the decoration is left unconsumed and rejects.

Fields§

§generated_column_shorthand: bool

Accept the keywordless generated-column shorthand <col> <type> AS (<expr>) [STORED|VIRTUAL], written without the leading GENERATED ALWAYS (MySQL, SQLite). It folds onto the one GeneratedColumn shape tagged GeneratedColumnSpelling::Shorthand, never a new node. PostgreSQL requires the GENERATED ALWAYS keywords, so this is off there and the bare AS (…) after a column type is left unconsumed and surfaces as a clean parse error.

§column_conflict_resolution_clause: bool

Accept the SQLite column-level ON CONFLICT <resolution> clause on an inline NOT NULL / UNIQUE / PRIMARY KEY / CHECK constraint (a INTEGER UNIQUE ON CONFLICT REPLACE), recording the resolution algorithm in ColumnConstraint::conflict. SQLite-only; off in every other preset, where the trailing ON after the constraint is left unconsumed and surfaces as a clean parse error. Split out of the retired sqlite_table_decorations bundle because column-level conflict resolution is an independent grammar point from the trailing table options, the typeless column, AUTOINCREMENT, and the inline-PRIMARY KEY ordering.

§typeless_column_definitions: bool

Accept a SQLite typeless column definition — a column named with no data type (CREATE TABLE t (a, b)), leaving ColumnDef::data_type unset. SQLite-only; off in every other preset, where a column with no type falls through to parse_data_type and surfaces as a clean parse error. Split out of the retired sqlite_table_decorations bundle because the typeless column is an independent grammar point from the trailing table options, AUTOINCREMENT, the column COLLATE, and the inline-PRIMARY KEY ordering.

§typeless_generated_columns: bool

Accept a column that omits its data type only when the column is a generated column — DuckDB’s narrowing of the SQLite typeless rule. DuckDB requires a data type on every column except a generated one: both the GENERATED { ALWAYS | BY DEFAULT } AS … form and the keywordless AS (<expr>) shorthand may drop the type (CREATE TABLE t (x INT, gen_x AS (x + 5)), engine-measured on libduckdb 1.5.4), while a plain typeless column (x) or a typeless non-generated constraint (y DEFAULT 5) is a parse error. On for DuckDB/Lenient. Off for ANSI/PostgreSQL/MySQL — a generated column with no type falls through to parse_data_type and surfaces as a clean parse error — and off for SQLite, which instead accepts any typeless column via the strictly wider typeless_column_definitions, so this narrow gate stays off there.

§joined_autoincrement_attribute: bool

Accept the SQLite joined AUTOINCREMENT column attribute — the bare one-word keyword on an inline PRIMARY KEY column (a INTEGER PRIMARY KEY AUTOINCREMENT), recorded as AutoIncrementSpelling::Joined so it round-trips as one word. SQLite-only; off in every other preset, where the trailing AUTOINCREMENT is left unconsumed and surfaces as a clean parse error. This gates only the joined spelling: the underscored MySQL AUTO_INCREMENT attribute is a separate surface gated by table_options, so the two spellings toggle independently and neither preset admits the other’s word. Split out of the retired sqlite_table_decorations bundle because the auto-increment attribute is an independent grammar point from the typeless column, the column COLLATE, and the inline-PRIMARY KEY ordering.

§inline_primary_key_ordering: bool

Accept an ASC/DESC sort-order qualifier on an inline PRIMARY KEY column constraint (CREATE TABLE t (a INTEGER PRIMARY KEY DESC)), recorded in the ColumnOption::PrimaryKey ascending field (ASCSome(true), DESCSome(false), absent → None). SQLite-only; off in every other preset, where the trailing ASC/DESC is left unconsumed and surfaces as a clean parse error. Split out of the retired sqlite_table_decorations bundle because the inline primary-key ordering is an independent grammar point from the trailing table options, the typeless column, AUTOINCREMENT, and the column COLLATE.

§named_column_collate_constraint: bool

Accept a CONSTRAINT <name> prefix on a column COLLATE clause (CREATE TABLE t (a TEXT CONSTRAINT c COLLATE nocase)): SQLite’s grammar makes COLLATE an ordinary nameable column constraint, so a CONSTRAINT <name> symbol binds to it. SQLite-only; off in every other preset (PostgreSQL and DuckDB engine-measured reject the named form, where COLLATE any_name is a constraint alternative parallel to — not under — the nameable constraint element), leaving the CONSTRAINT <name> prefix on a COLLATE clause as a clean parse error. This gates only the named wrapper: the bare column COLLATE surface (ColumnOption::Collate) is a separate cross-dialect shape gated by column_collation, so the accepting case needs both flags on. Split out of the retired sqlite_table_decorations bundle because the named-COLLATE wrapper is an independent grammar point from the inline-PRIMARY KEY ordering.

§identity_columns: bool

Accept the <col> <type> GENERATED { ALWAYS | BY DEFAULT } AS IDENTITY [(…)] identity column (SQL:2003; PostgreSQL). On for ANSI/PostgreSQL/MySQL/DuckDB/ Lenient. SQLite has no IDENTITY (its auto-key is INTEGER PRIMARY KEY [AUTOINCREMENT]), so it is off; the IDENTITY keyword is then left unconsumed and surfaces as a clean parse error. Gates only the AS IDENTITY reading — the GENERATED ALWAYS AS (<expr>) computed column (which SQLite has) is unaffected.

§compact_identity_columns: bool

Accept the compact identity-column forms <col> <type> IDENTITY and <col> <type> IDENTITY(<seed>, <increment>). The two numeric arguments map to the same start/increment identity options as the standard generated form.

§default_expression_requires_parens: bool

Require a parenthesized DEFAULT (expr) for a functional / general-expression column default. On for MySQL: a column DEFAULT there admits only a literal, a signed literal, the CURRENT_TIMESTAMP/NOW()/LOCALTIME/LOCALTIMESTAMP temporal family, or a parenthesized expression — a bare function call or operator expression (DEFAULT UUID(), DEFAULT 1 + 2) is an ER_PARSE_ERROR on mysql:8, while DEFAULT (UUID()) parses. Off for ANSI/PostgreSQL/SQLite/DuckDB/Lenient, which accept a bare expression default. When off, the default expression is read whole with no wrapping requirement.

§column_default_requires_b_expr: bool

Restrict a column-constraint DEFAULT to PostgreSQL’s b_expr grammar class (ColConstraintElem: DEFAULT b_expr), rather than the full a_expr used everywhere else. b_expr is the “boolean-and-predicate-free” expression production: it keeps arithmetic, comparison, ||, OPERATOR(...), ::, subscripts, COLLATE, and the IS [NOT] DISTINCT FROM / IS [NOT] DOCUMENT tests, but excludes the a_expr-only forms — AND/OR/NOT, IN, BETWEEN, LIKE/ILIKE/SIMILAR TO, IS [NOT] NULL/TRUE/FALSE/UNKNOWN, a quantified = ANY(...), and AT TIME ZONE. So ... DEFAULT 1 IN (1, 2) is a syntax error on PostgreSQL (the IN predicate is a_expr-level), while the parenthesized DEFAULT (1 IN (1, 2)) — a c_expr reset to a_expr — parses. On for PostgreSQL only; every other dialect (including DuckDB, which otherwise inherits the PostgreSQL schema surface) reads the default as a full a_expr. Note the asymmetry: ALTER COLUMN ... SET DEFAULT is a_expr even on PostgreSQL, so this gates only the inline column-constraint site.

§column_collation: bool

Accept the column-definition COLLATE <collation> clause (a text COLLATE "C"). On for PostgreSQL/SQLite/DuckDB/Lenient — all three spell a per-column collation inside the column definition (PostgreSQL takes a qualified any_name, SQLite/DuckDB a single bare identifier; the parser narrows the name grammar per dialect). Off for ANSI/MySQL, where a column-level COLLATE is left unconsumed and surfaces as a clean parse error. Distinct from the expression-level COLLATE gated by ExpressionSyntax::collate on a different sub-struct — this one qualifies a column, not an expression. (MySQL does spell a column COLLATE in its own CHARACTER SET … COLLATE … attribute grammar, a distinct surface left to a follow-up.)

§column_storage: bool

Accept the per-column STORAGE {PLAIN | EXTERNAL | EXTENDED | MAIN | DEFAULT} and COMPRESSION <method> physical-storage clauses (PostgreSQL). The two travel together as a single dialect unit — both are fixed-position clauses between a column’s type and its constraint list. On for PostgreSQL/Lenient. Off for ANSI/MySQL/SQLite/DuckDB (DuckDB, which otherwise inherits the PostgreSQL schema surface, rejects both), where the STORAGE/COMPRESSION keyword is left unconsumed and surfaces as a clean parse error.

Implementations§

Source§

impl ColumnDefinitionSyntax

Source

pub const ANSI: Self

The ANSI predefined value.

Source§

impl ColumnDefinitionSyntax

Source

pub const LENIENT: Self

Available on crate feature lenient only.

The LENIENT preset for column definition syntax.

Source§

impl ColumnDefinitionSyntax

Source

pub const MYSQL: Self

Available on crate feature mysql only.

The MYSQL preset for column definition syntax.

Source§

impl ColumnDefinitionSyntax

Source

pub const POSTGRES: Self

Available on crate feature postgres only.

The POSTGRES preset for column definition syntax.

Source§

impl ColumnDefinitionSyntax

Source

pub const QUILTDB: Self

Available on crate feature quiltdb only.

Column-definition syntax enabled by this preset.

Source§

impl ColumnDefinitionSyntax

Source

pub const SQLITE: Self

Available on crate feature sqlite only.

The SQLITE preset for column definition syntax.

Trait Implementations§

Source§

impl Clone for ColumnDefinitionSyntax

Source§

fn clone(&self) -> ColumnDefinitionSyntax

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 Copy for ColumnDefinitionSyntax

Source§

impl Debug for ColumnDefinitionSyntax

Source§

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

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

impl Eq for ColumnDefinitionSyntax

Source§

impl PartialEq for ColumnDefinitionSyntax

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ColumnDefinitionSyntax

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