pub struct PredicateSyntax {
pub like: bool,
pub ilike: bool,
pub similar_to: bool,
pub overlaps_period_predicate: bool,
pub unparenthesized_in_list: bool,
pub pattern_match_quantifier: bool,
pub between_symmetric: bool,
pub is_normalized: bool,
pub empty_in_list: bool,
pub null_test_two_word_postfix: bool,
}Expand description
Dialect-owned predicate-form syntax accepted by the parser.
The dialect-gated predicate forms beyond the always-available comparison / IS / IN
baseline. They are predicates (non-chaining, comparison precedence), distinct from the
ExpressionSyntax postfix/constructor forms, and — unlike those — not all PostgreSQL
extensions: some are SQL Core surface on in every shipped dialect (LIKE, SQL-92 /
SQL:2016 Core E021-08), while the rest are gated per dialect. Each is a pure grammar
gate: when off, the keyword is left unconsumed and the trailing operand surfaces as a
clean parse error — the same reject mechanism the other syntax gates use.
Fields§
§like: boolAccept <expr> [NOT] LIKE <pattern> [ESCAPE <c>] (SQL-92 core E021-08). On in
every dialect — this is the standard pattern-match predicate.
ilike: boolAccept <expr> [NOT] ILIKE <pattern> [ESCAPE <c>] case-insensitive matching
(PostgreSQL).
similar_to: boolAccept <expr> [NOT] SIMILAR TO <pattern> [ESCAPE <c>] regex matching
(SQL:1999 F841; PostgreSQL).
overlaps_period_predicate: boolAccept the SQL-standard (s1, e1) OVERLAPS (s2, e2) period predicate (SQL:2016
F251) — the row OVERLAPS row form yielding a boolean, both operands
exactly-two-element rows (a bare parenthesized pair or ROW(...)). A pure grammar
gate: when off, the OVERLAPS keyword is left unconsumed and surfaces as a clean
parse error. The parser enforces the two-element-row operand shape on both sides
(a scalar, a single-element grouping (a), or a three-element row is rejected,
matching PostgreSQL’s grammar-level wrong-arity error), so a value stored here only
opens the predicate — validity of the operands is still checked. PostgreSQL-only
among the shipped presets (DuckDB, MySQL, and SQLite all reject the form,
engine-probed); the Lenient union carries it too.
unparenthesized_in_list: boolAccept DuckDB’s unparenthesized <expr> [NOT] IN <value> list-membership operator
(Expr::InExpr) — z IN y, distinct from the standard
parenthesized IN (list) / IN (subquery). DuckDB-only: the right operand is a
restricted c_expr that may not begin with a constant or unary sign (IN 4 / IN -5 are DuckDB parser errors), so the parser gates on the leading token. Off in
every non-DuckDB preset (PostgreSQL and the standard require the parentheses).
pattern_match_quantifier: boolAccept a pattern-match predicate quantified over an array operand: <expr> [NOT] LIKE|ILIKE {ANY | ALL | SOME} (<array>)
(Expr::QuantifiedLike) — PostgreSQL’s
ScalarArrayOpExpr over the ~~/~~* operator. SIMILAR TO has no
quantified form (PostgreSQL rejects it, engine-probed), so only LIKE/ILIKE
open it. A pure grammar gate: when off, the ANY/ALL/SOME head after a
pattern operator is left unconsumed and surfaces as the usual reject at the
reserved quantifier keyword. PostgreSQL-only among the shipped presets; the
Lenient union carries it too.
between_symmetric: boolAccept the SQL-standard SYMMETRIC/ASYMMETRIC modifier on the range predicate:
<expr> [NOT] BETWEEN {SYMMETRIC | ASYMMETRIC} <low> AND <high> (SQL:2016 T461).
SYMMETRIC is load-bearing — it permits low > high by testing against the ordered
pair — and is kept on Expr::Between’s symmetric flag;
the default ASYMMETRIC is a noise word dropped on parse. A pure grammar gate: when
off, the modifier keyword after BETWEEN is left unconsumed and surfaces as a clean
parse error. SYMMETRIC is an optional standard feature (T461), so it stays off in
the strict ANSI baseline (and thus in MySQL/SQLite/ClickHouse/Snowflake, which reuse
PredicateSyntax::ANSI and reject the modifier); on for PostgreSQL (engine-probed on
pg_query) and the Lenient union.
is_normalized: boolAccept the SQL-standard Unicode-normalization test <expr> IS [NOT] [NFC|NFD|NFKC|NFKD] NORMALIZED (SQL:2016 T061), parsed to the postfix
Expr::IsNormalized predicate. A pure grammar gate:
when off, the NORMALIZED continuation after IS [NOT] is left unconsumed and the
null/truth reading rejects it. An optional standard feature, so off in the strict ANSI
baseline (and thus in MySQL/SQLite/ClickHouse/Snowflake, which reuse
PredicateSyntax::ANSI and reject it); on for PostgreSQL (engine-probed on pg_query)
and the Lenient union.
empty_in_list: boolAccept an empty parenthesized IN list — <expr> [NOT] IN () — with no elements,
parsed to an Expr::InList whose list is empty. SQLite
evaluates x IN () to false and x NOT IN () to true (engine-measured via rusqlite
3.53.2, where both prepare-accept). A pure grammar gate: when off, the closing ) in
list position is left unconsumed and the required-first-element reject stands — the
standard IN predicate demands at least one element, so ANSI/PostgreSQL/MySQL/DuckDB
syntax-reject the empty list. On for SQLite and the Lenient union, off elsewhere.
null_test_two_word_postfix: boolAccept the two-word postfix null test <expr> NOT NULL (a synonym for IS NOT NULL),
folded onto Expr::IsNull with negated: true and a
NullTestSpelling::PostfixNotNull tag so it round-trips.
A NOT-led predicate spelling, parsed at comparison precedence alongside the other
NOT-led predicates (NOT IN/NOT LIKE/NOT BETWEEN); when off, the NOT NULL run is
left unconsumed and the NOT surfaces as the ordinary prefix operator (or a clean parse
error), so the two-word form is rejected.
Distinct from the one-word OperatorSyntax::null_test_postfix gate
because the surfaces diverge (engine-measured): SQLite and DuckDB accept both spellings,
but PostgreSQL — despite accepting the one-word ISNULL/NOTNULL — rejects the two-word
NOT NULL postfix. On for SQLite and the Lenient union; off elsewhere (including
PostgreSQL; DuckDB’s acceptance is tracked separately).
Implementations§
Trait Implementations§
Source§impl Clone for PredicateSyntax
impl Clone for PredicateSyntax
Source§fn clone(&self) -> PredicateSyntax
fn clone(&self) -> PredicateSyntax
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more