Skip to main content

ExistenceGuards

Struct ExistenceGuards 

Source
pub struct ExistenceGuards {
    pub if_exists: bool,
    pub view_if_not_exists: bool,
    pub create_database_if_not_exists: bool,
}
Expand description

Dialect-owned IF [NOT] EXISTS existence guards on DDL statements.

The SQL existence guards — IF EXISTS on DROP/ALTER, IF NOT EXISTS on CREATE — are dialect data: each flag decides whether the parser admits the guard at one statement site, and when off the IF [NOT] EXISTS is left unconsumed and surfaces as a clean parse error (the same reject mechanism the other grammar gates use). They live in their own sub-struct rather than scattered through the retired SchemaChangeSyntax because their bundle membership differs per dialect: leaving a coarse if_exists bundle in SchemaChangeSyntax made every new dialect bolt on a separate exception flag (view_if_not_exists, create_database_if_not_exists), so a dedicated per-site table is the shape that does not accrete one exception per dialect.

Two-level spelling convention (uniform across the dialect-data knobs): a top-level FeatureSet assembly spells every field explicitly, while a sub-preset const of a knob like this one may struct-update-derive from a sibling with ..Self::OTHER (the SelectSyntax::DUCKDB precedent) — the base preset stays the exhaustive source of truth and the derived one records only its deltas.

Fields§

§if_exists: bool

Accept IF EXISTS on DROP/ALTER TABLE (and on their column/constraint sub-actions) and IF NOT EXISTS on ADD COLUMN (PostgreSQL, MySQL, SQLite; not ANSI, whose DROP/ALTER has no existence guard). One flag gates the drop/alter/add-column existence guards together because a dialect that spells one spells them all; the ALTER TABLE/ADD COLUMN sites additionally require IndexAlterSyntax::alter_table_extended (SQLite keeps this guard on for its DROP … IF EXISTS while its plain-ALTER surface stays off).

§view_if_not_exists: bool

Accept IF NOT EXISTS on a plain (non-materialized) CREATE VIEW (SQLite). PostgreSQL admits IF NOT EXISTS only on a CREATE MATERIALIZED VIEW (that form is always accepted, independent of this flag), and MySQL has no view existence guard at all, so off there; SQLite spells CREATE VIEW IF NOT EXISTS over a regular view. When off, the IF NOT EXISTS is left unconsumed on a plain view and surfaces as a clean parse error.

§create_database_if_not_exists: bool

Accept the CREATE DATABASE IF NOT EXISTS <name> existence guard (MySQL; also SQLite has no CREATE DATABASE at all, so off there). PostgreSQL’s CREATE DATABASE has no IF NOT EXISTS, so this is a dedicated site rather than a reuse of if_exists — that one is on in PostgreSQL, which must still reject CREATE DATABASE IF NOT EXISTS. When off, the IF NOT EXISTS is left unconsumed and surfaces as a clean parse error.

Implementations§

Source§

impl ExistenceGuards

Source

pub const ANSI: Self

The ANSI predefined value.

Source§

impl ExistenceGuards

Source

pub const LENIENT: Self

Available on crate feature lenient only.

The LENIENT preset for existence guards.

Source§

impl ExistenceGuards

Source

pub const MYSQL: Self

Available on crate feature mysql only.

The MYSQL preset for existence guards.

Source§

impl ExistenceGuards

Source

pub const POSTGRES: Self

Available on crate feature postgres only.

The POSTGRES preset for existence guards.

Source§

impl ExistenceGuards

Source

pub const SQLITE: Self

Available on crate feature sqlite only.

The SQLITE preset for existence guards.

Trait Implementations§

Source§

impl Clone for ExistenceGuards

Source§

fn clone(&self) -> ExistenceGuards

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 ExistenceGuards

Source§

impl Debug for ExistenceGuards

Source§

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

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

impl Eq for ExistenceGuards

Source§

impl PartialEq for ExistenceGuards

Source§

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

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.