Skip to main content

IdentifierSyntax

Struct IdentifierSyntax 

Source
pub struct IdentifierSyntax {
    pub non_ascii: NonAsciiIdentifierSyntax,
    pub dollar_in_identifiers: bool,
    pub string_literal_identifiers: bool,
    pub string_literal_table_names: bool,
    pub empty_quoted_identifiers: bool,
}
Expand description

Dialect-owned policy for which characters form an unquoted identifier.

The identifier-start and identifier-continue classes are an explicit, Unicode-aware policy, not an ad-hoc byte rule. ANSI starts with a Unicode letter (char::is_alphabetic) or _, and continues with a letter, a Unicode digit (char::is_alphanumeric), _, or — where dollar_in_identifiers is set — $. PostgreSQL, MySQL, and SQLite instead admit every non-ASCII code point. Quoted identifiers bypass the policy entirely (any character may be quoted), and no identifier normalization (NFC/NFKC) is performed — characters are compared as written; case folding for identity is the separate identifier_casing concern.

Only the dialect-variable part lives here. The ASCII letter/digit/_ classes are the shared byte-class table (so a dialect can still add ASCII identifier bytes like T-SQL #/@ through byte_classes); non_ascii selects the non-ASCII rule.

Fields§

§non_ascii: NonAsciiIdentifierSyntax

Select the non-ASCII start/continue policy. ASCII characters remain governed by FeatureSet::byte_classes.

§dollar_in_identifiers: bool

Accept $ as an identifier-continue character (foo$bar), a PostgreSQL / Oracle extension that strict ANSI forbids. $ never starts an identifier (a leading $ is a parameter or dollar-quote), and it is never a dollar-quote tag character (there $ is the delimiter).

§string_literal_identifiers: bool

Accept a single-quoted string literal in identifier positions beyond aliases — SQLite’s misfeature where a 'name' string is read as a name wherever the grammar wants a nm (identifier). Corpus-admitted for the two positions the SQLite test-suite surfaces: a DML/DDL relation-target name (DELETE FROM 'table1', and so CREATE TABLE 'name' / DROP TABLE 'n' / INSERT INTO 'n' through the shared target path) and a PRIMARY KEY/UNIQUE table-constraint column-name list (PRIMARY KEY('a'), UNIQUE('b')). Each admitted position is position-driven: a bare string there is never a valid literal in standard SQL, so reading it as the name is unambiguous — no lexical or grammar conflict (the tokenizer still lexes 'x' to a String; a single parser position reads it, shadowing no rival feature).

SQLite’s full leniency is broader (a string is also admitted as a column-def name, a CAST type name, a qualified column-ref qualifier, a CREATE VIEW/TRIGGER target, …); those positions carry no corpus gap and stay out of scope. A string function name is a SQLite syntax error (SELECT 'f'(1)), so the widening is deliberately confined to the two name positions rather than folded into the shared object-name grammar. The folded name records QuoteStyle::Single (or Double under a no-ANSI_QUOTES mode) so the quotes round-trip, reusing the projection alias’s string round-trip. On for SQLite / Lenient, off elsewhere — every other dialect syntax-rejects the form, so the over-acceptance risk is zero (flag off).

§string_literal_table_names: bool

Accept a single-part Sconst spelling of a relation / table name — DuckDB’s FROM 't' / FROM '' / FROM E't' / FROM $$t$$ (engine-measured on libduckdb 1.5.4). The string is a single-part name only: a dotted string name (FROM 'a'.'b') is a parser reject, matching DuckDB. Distinct from string_literal_identifiers (SQLite’s broader multi-part 'schema'.'table' misfeature on relation targets). On for DuckDB and the permissive superset; off elsewhere.

§empty_quoted_identifiers: bool

Accept a zero-length delimited (quoted) identifier — the empty backtick , the empty bracket `[]`, and the empty double-quote `""` — which SQL's `<delimited identifier body>` and PostgreSQL/MySQL both forbid at scan time. SQLite alone among the shipped engines admits an empty quoted identifier in every quote style (engine-measured on rusqlite: SELECT , SELECT [], and SELECT "" all prepare — the "" via SQLite’s double-quote-to-string fallback, the others as zero-length names). When off, the tokenizer rejects a zero-length quoted identifier the moment the close abuts the open (the pre-existing, universal ZeroLengthDelimitedIdentifier scan reject). On for SQLite / Lenient, off elsewhere.

Implementations§

Source§

impl IdentifierSyntax

Source

pub const ANSI: Self

The ANSI predefined value.

Source§

impl IdentifierSyntax

Source

pub const LENIENT: Self

Available on crate feature lenient only.

LENIENT: accept $ as an identifier-continue byte (PostgreSQL/MySQL). A leading $+digit still dispatches to the parameter form — $ only continues an identifier, it does not start one — so this does not conflict with rule 3.

Source§

impl IdentifierSyntax

Source

pub const MYSQL: Self

Available on crate feature mysql only.

The MYSQL preset for identifier syntax.

Source§

impl IdentifierSyntax

Source

pub const POSTGRES: Self

Available on crate feature postgres only.

The POSTGRES preset for identifier syntax.

Source§

impl IdentifierSyntax

Source

pub const SQLITE: Self

Available on crate feature sqlite only.

The SQLITE preset for identifier syntax.

Trait Implementations§

Source§

impl Clone for IdentifierSyntax

Source§

fn clone(&self) -> IdentifierSyntax

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 IdentifierSyntax

Source§

impl Debug for IdentifierSyntax

Source§

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

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

impl Eq for IdentifierSyntax

Source§

impl PartialEq for IdentifierSyntax

Source§

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

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.