pub struct ParameterSyntax {
pub positional_dollar: 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: boolAccept 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.
anonymous_question: boolAccept anonymous positional ? placeholders (ODBC/JDBC).
named_colon: boolAccept 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: boolAccept 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: boolAccept 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: boolAccept 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
impl ParameterSyntax
Sourcepub const LENIENT: Self
Available on crate feature lenient only.
pub const LENIENT: Self
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
impl ParameterSyntax
Sourcepub const MSSQL: Self
Available on crate feature mssql only.
pub const MSSQL: Self
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.
Trait Implementations§
Source§impl Clone for ParameterSyntax
impl Clone for ParameterSyntax
Source§fn clone(&self) -> ParameterSyntax
fn clone(&self) -> ParameterSyntax
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more