Skip to main content

ParameterSyntax

Struct ParameterSyntax 

Source
pub struct ParameterSyntax {
    pub positional_dollar: bool,
    pub positional_dollar_large: bool,
    pub anonymous_question: bool,
    pub named_colon: bool,
    pub named_at: bool,
    pub named_dollar: bool,
    pub numbered_question: bool,
}
Expand description

Dialect-owned prepared-statement parameter placeholder syntax.

SQL has no single standard placeholder spelling, so which forms a dialect accepts is explicit dialect data, not a parser-side type check. Each flag is a lexical gate: it decides whether the scanner recognises that sigil as a parameter TokenKind rather than a stray byte.

Fields§

§positional_dollar: bool

Accept PostgreSQL positional $1, $2, … ($ + ASCII digits). Disjoint from dollar-quoting: $ + digit is a parameter, $ + tag-start/$ opens a dollar-quoted string, so both forms can be enabled together.

§positional_dollar_large: bool

Preserve a $ positional parameter whose digit run exceeds u32. PostgreSQL’s scanner accepts these spellings and narrows them into its signed ParamRef.number; dialects that range-check their parameter indices leave this off.

§anonymous_question: bool

Accept anonymous positional ? placeholders (ODBC/JDBC).

§named_colon: bool

Accept colon-named :name placeholders (Oracle, SQLite, JDBC/psycopg). The sigil must abut an identifier-start byte, which is what keeps :name free of the two other : meanings: :: stays the typecast (its second : is not an identifier byte) and a lone : before a non-identifier byte stays the array-slice separator. (A dialect that also sliced arrays with bare identifier bounds — a[x:y] — or wrote semi-structured paths as a:b would lex :y/:b as a parameter; that pairing is the tracked LexicalConflict::ColonParameterVersusSliceBound, since no real dialect combines :name with those spellings.)

§named_at: bool

Accept at-sign-named @name placeholders (T-SQL parameters/local variables). The sigil must abut an identifier-start byte, so the system-variable @@name form is left unclaimed for prod-token-identifier-prefix-tokens (the second @ is not an identifier byte, so this never grabs @@).

Mutually exclusive with SessionVariableSyntax::user_variables: both claim the @name trigger (one as a placeholder, one as a user-variable read), so a feature set enabling both is a LexicalConflict. @name-as-parameter (T-SQL) and @name-as-user-variable (MySQL) are the same surface with different meaning, so a dialect picks one.

§named_dollar: bool

Accept dollar-named $name placeholders (SQLite). The sigil must abut an identifier-start byte — $ + a digit stays the PostgreSQL positional $1 (positional_dollar) and $ + a non-identifier byte a stray/money form — so this is follow-set-disjoint from both $-digit forms and can be enabled alongside them.

Contends only with StringLiteralSyntax::dollar_quoted_strings: a $tag$…$tag$ opener also leads with $ + a tag-start byte (the same class as identifier-start), so enabling both is a LexicalConflict::NamedDollarParameterVersusDollarQuotedString. SQLite has no dollar-quoting, so the two never meet in a shipped preset.

§numbered_question: bool

Accept SQLite numbered ?NNN positional parameters (?1, ?123) — the ? sigil abutting an ASCII-digit run — on top of the bare anonymous ? (anonymous_question). Follow-set-disjoint from the anonymous form by the digit (a ? with no digit stays anonymous), exactly as PostgreSQL’s $1 splits from $name. The number is a maximal digit run, so a trailing identifier is a separate token (?1abc is ?1 then the alias abc; engine-measured). SQLite range-restricts the index to 1..=32766 (SQLITE_MAX_VARIABLE_NUMBER): ?0, ?32767, and an overflowing run are parse rejects (“variable number must be between ?1 and ?32766”; probed), enforced when the numbered token is materialised. On for SQLite / Lenient, off elsewhere.

Implementations§

Source§

impl ParameterSyntax

Source

pub const ANSI: Self

The ANSI predefined value.

Source§

impl ParameterSyntax

Source

pub const LENIENT: Self

Available on crate feature lenient only.

LENIENT: every placeholder spelling — PostgreSQL $1, ODBC/JDBC ?, Oracle/SQLite :name, and T-SQL @name. The sigils are lookahead-disjoint, so enabling all four is a pure addition. @name keeps its parameter meaning under LENIENT (named_at), so user_variables stays off in SessionVariableSyntax::LENIENT — the two claim the same @name trigger — but the disjoint @@sysvar form is still admitted there.

The SQLite $name form (named_dollar) is the one placeholder left off: it contends with the PostgreSQL $tag$…$tag$ dollar-quote this union already admits (StringLiteralSyntax::LENIENT, both lead with $+identifier), so the union resolves that $ trigger to dollar-quoting — the spelled-out conflict-resolution the LENIENT honesty bar requires.

Source§

impl ParameterSyntax

Source

pub const MSSQL: Self

Available on crate feature mssql only.

MSSQL parameter surface: the ANSI baseline plus the @name parameter / local-variable sigil. positional_dollar stays off (ANSI’s value) so $+digit belongs solely to NumericLiteralSyntax::money_literals, and user_variables stays off (in SessionVariableSyntax::ANSI) so @name belongs solely to this — both enforced by the lexical assert below.

Source§

impl ParameterSyntax

Source

pub const MYSQL: Self

Available on crate feature mysql only.

The MYSQL preset for parameter syntax.

Source§

impl ParameterSyntax

Source

pub const POSTGRES: Self

Available on crate feature postgres only.

The POSTGRES preset for parameter syntax.

Source§

impl ParameterSyntax

Source

pub const SQLITE: Self

Available on crate feature sqlite only.

The SQLITE preset for parameter syntax.

Trait Implementations§

Source§

impl Clone for ParameterSyntax

Source§

fn clone(&self) -> ParameterSyntax

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 ParameterSyntax

Source§

impl Debug for ParameterSyntax

Source§

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

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

impl Eq for ParameterSyntax

Source§

impl PartialEq for ParameterSyntax

Source§

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

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.