Skip to main content

TableConstraint

Enum TableConstraint 

Source
pub enum TableConstraint {
    PrimaryKey {
        name: Option<Identifier>,
        columns: Vec<Identifier>,
        include_columns: Vec<Identifier>,
        modifiers: ConstraintModifiers,
        has_constraint_keyword: bool,
    },
    Unique {
        name: Option<Identifier>,
        columns: Vec<Identifier>,
        columns_parenthesized: bool,
        modifiers: ConstraintModifiers,
        has_constraint_keyword: bool,
        nulls_not_distinct: bool,
    },
    ForeignKey {
        name: Option<Identifier>,
        columns: Vec<Identifier>,
        references: Option<ForeignKeyRef>,
        on_delete: Option<ReferentialAction>,
        on_update: Option<ReferentialAction>,
        modifiers: ConstraintModifiers,
    },
    Check {
        name: Option<Identifier>,
        expression: Expression,
        modifiers: ConstraintModifiers,
    },
    Index {
        name: Option<Identifier>,
        columns: Vec<Identifier>,
        kind: Option<String>,
        modifiers: ConstraintModifiers,
        use_key_keyword: bool,
        expression: Option<Box<Expression>>,
        index_type: Option<Box<Expression>>,
        granularity: Option<Box<Expression>>,
    },
    Projection {
        name: Identifier,
        expression: Expression,
    },
    Like {
        source: TableRef,
        options: Vec<(LikeOptionAction, String)>,
    },
    PeriodForSystemTime {
        start_col: Identifier,
        end_col: Identifier,
    },
    Exclude {
        name: Option<Identifier>,
        using: Option<String>,
        elements: Vec<ExcludeElement>,
        include_columns: Vec<Identifier>,
        where_clause: Option<Box<Expression>>,
        with_params: Vec<(String, String)>,
        using_index_tablespace: Option<String>,
        modifiers: ConstraintModifiers,
    },
    Tags(Tags),
    InitiallyDeferred {
        deferred: bool,
    },
}
Expand description

Table-level constraint

Variants§

§

PrimaryKey

Fields

§columns: Vec<Identifier>
§include_columns: Vec<Identifier>

INCLUDE (columns) - non-key columns included in the index (PostgreSQL)

§has_constraint_keyword: bool

Whether the CONSTRAINT keyword was used (vs MySQL’s PRIMARY KEY name (cols) syntax)

§

Unique

Fields

§columns: Vec<Identifier>
§columns_parenthesized: bool

Whether columns are parenthesized (false for UNIQUE idx_name without parens)

§has_constraint_keyword: bool

Whether the CONSTRAINT keyword was used (vs MySQL’s UNIQUE name (cols) syntax)

§nulls_not_distinct: bool

PostgreSQL 15+: NULLS NOT DISTINCT

§

ForeignKey

Fields

§columns: Vec<Identifier>
§references: Option<ForeignKeyRef>
§on_delete: Option<ReferentialAction>

ON DELETE action when REFERENCES is absent

§on_update: Option<ReferentialAction>

ON UPDATE action when REFERENCES is absent

§

Check

Fields

§expression: Expression
§

Index

INDEX / KEY constraint (MySQL)

Fields

§columns: Vec<Identifier>
§kind: Option<String>

Index kind: UNIQUE, FULLTEXT, SPATIAL, etc.

§use_key_keyword: bool

True if KEY keyword was used instead of INDEX

§expression: Option<Box<Expression>>

ClickHouse: indexed expression (instead of columns)

§index_type: Option<Box<Expression>>

ClickHouse: TYPE type_func(args)

§granularity: Option<Box<Expression>>

ClickHouse: GRANULARITY n

§

Projection

ClickHouse PROJECTION definition

Fields

§expression: Expression
§

Like

PostgreSQL LIKE clause: LIKE source_table [INCLUDING|EXCLUDING options]

Fields

§source: TableRef
§options: Vec<(LikeOptionAction, String)>

Options as (INCLUDING|EXCLUDING, property) pairs

§

PeriodForSystemTime

TSQL PERIOD FOR SYSTEM_TIME (start_col, end_col)

Fields

§start_col: Identifier
§end_col: Identifier
§

Exclude

PostgreSQL EXCLUDE constraint EXCLUDE [USING method] (element WITH operator, …) [INCLUDE (cols)] [WHERE (expr)] [WITH (params)]

Fields

§using: Option<String>

Index access method (gist, btree, etc.)

§elements: Vec<ExcludeElement>

Elements: (expression, operator) pairs

§include_columns: Vec<Identifier>

INCLUDE columns

§where_clause: Option<Box<Expression>>

WHERE predicate

§with_params: Vec<(String, String)>

WITH (storage_parameters)

§using_index_tablespace: Option<String>

USING INDEX TABLESPACE tablespace_name

§

Tags(Tags)

Snowflake TAG clause: TAG (key=‘value’, key2=‘value2’)

§

InitiallyDeferred

PostgreSQL table-level INITIALLY DEFERRED/INITIALLY IMMEDIATE This is a standalone clause at the end of the CREATE TABLE that sets the default for all deferrable constraints in the table

Fields

§deferred: bool

true = INITIALLY DEFERRED, false = INITIALLY IMMEDIATE

Trait Implementations§

Source§

impl Clone for TableConstraint

Source§

fn clone(&self) -> TableConstraint

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for TableConstraint

Source§

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

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

impl<'de> Deserialize<'de> for TableConstraint

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for TableConstraint

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 Serialize for TableConstraint

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for TableConstraint

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,