Skip to main content

Dialect

Struct Dialect 

Source
pub struct Dialect {
    pub backslash_escapes: bool,
    pub double_quoted_identifiers: bool,
    pub speaks_mysql: bool,
}
Expand description

v7.22 (round-13 T3) — dialect-aware tokenizer entry. With backslash_escapes = true, plain '…' strings honour MySQL / pre-9.1-PG backslash escapes (\' \\ \n …, the same decode the E'…' form uses). mysqldump ALWAYS emits \'-escaped data sections, and pg_dump ALWAYS announces PG semantics via SET standard_conforming_strings = on — the engine flips this flag off/on from those deterministic session signals. How a statement’s text is to be read.

v7.39 — this was a lone bool. The second axis is ANSI_QUOTES, which SPG behaved as though were always on: measured on MySQL 9.7.2, SELECT "abc" answers abc, while a MySQL session on SPG answered ERROR 1054 column "abc" does not exist. Ordinary MySQL SQL that quotes a string with " — which a great deal of it does — failed with an error naming a column the author never wrote.

Fields§

§backslash_escapes: bool

\ escapes inside a string and # starts a comment: MySQL and MariaDB, unless the session’s sql_mode says NO_BACKSLASH_ESCAPES.

§double_quoted_identifiers: bool

"…" quotes an IDENTIFIER rather than a string literal.

PostgreSQL, always. MySQL only when ANSI_QUOTES is in sql_mode, which its default list does not carry.

§speaks_mysql: bool

v7.39.2 — does the session speak MySQL at all?

The parser asked backslash_escapes this, which is a different question: SET sql_mode='NO_BACKSLASH_ESCAPES' turned the escapes off and took the whole grammar with it, so 7 DIV 2 stopped parsing and 'a' || 'b' went back to concatenating where MySQL 9.7.2 answers 0.

Implementations§

Source§

impl Dialect

Source

pub const PG: Self

PostgreSQL: no backslash escapes, "…" is an identifier.

Trait Implementations§

Source§

impl Clone for Dialect

Source§

fn clone(&self) -> Dialect

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 Dialect

Source§

impl Debug for Dialect

Source§

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

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

impl Default for Dialect

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for Dialect

Source§

impl PartialEq for Dialect

Source§

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

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 = !

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.