pub enum BinaryOperator {
Show 42 variants
Plus,
Minus,
Multiply,
Divide,
Modulo(ModuloSpelling),
IntegerDivide(IntegerDivideSpelling),
Exponent,
StringConcat,
Contains,
ContainedBy,
StartsWith,
Overlap,
JsonGet,
JsonGetText,
JsonExists,
JsonExistsAny,
JsonExistsAll,
JsonPathExists,
JsonPathMatch,
JsonExtractPath,
JsonExtractPathText,
JsonDeletePath,
BitwiseOr,
BitwiseAnd,
BitwiseShiftLeft,
BitwiseShiftRight,
BitwiseXor(BitwiseXorSpelling),
Eq(EqualsSpelling),
NotEq(NotEqSpelling),
Lt,
LtEq,
Gt,
GtEq,
IsDistinctFrom(IsDistinctFromSpelling),
IsNotDistinctFrom(IsNotDistinctFromSpelling),
Regexp(RegexpSpelling),
Glob,
Match,
Overlaps,
And,
Xor,
Or,
}Expand description
Closed operator keys for dialect binding-power tables.
Variants§
Plus
+ — addition.
Minus
- — subtraction.
Multiply
* — multiplication.
Divide
/ — division.
Modulo(ModuloSpelling)
Modulo, spelled % everywhere and additionally MOD in MySQL. The two
spellings are one operator; the ModuloSpelling tag records
which the source used so it round-trips.
IntegerDivide(IntegerDivideSpelling)
Integer division — a distinct operator from / (it truncates to an integer), so
it gets its own key rather than reusing Divide. Two
dialect-disjoint spellings fold onto it: MySQL’s DIV keyword and
DuckDB’s // symbol; the IntegerDivideSpelling tag records which the source
used so it round-trips. Binds at multiplicative precedence.
Exponent
Arithmetic exponentiation, spelled ^. A distinct operator from the
BitwiseXor ^ (a dialect gives the ^ lexeme one meaning or the
other — engine truth): under
CaretOperator::Exponent
(PostgreSQL/DuckDB) ^ is arithmetic power,
and binds at its OWN precedence tier — tighter than *///%
(multiplicative) and looser
than the unary sign, left-associative (2 ^ 3 ^ 2 is (2 ^ 3) ^ 2, 2 ^ 3 * 2 is
(2 ^ 3) * 2 — engine-measured on pg_query). Its binding power is the dedicated
exponent row, not the multiplicative
rank the other arithmetic operators share.
StringConcat
|| — string concatenation.
Contains
PostgreSQL @> containment — “left contains right” over arrays, ranges, and
jsonb. Binds at PostgreSQL’s “any other operator” precedence (the rank shared
with StringConcat), left-associative.
ContainedBy
PostgreSQL <@ containment — “left is contained by right”, the mirror of
Contains. Same “any other operator” precedence.
StartsWith
DuckDB ^@ — “left string starts with right string”. Binds at the “any other
operator” precedence. Gated by starts_with_operator.
Overlap
The && overlap operator — “do the two operands overlap?” over arrays, ranges
(PostgreSQL), and geometries (DuckDB, whose && is bounding-box overlap). The one
operator key for the && spelling across dialects that give it this meaning:
DuckDB routes it here through DoubleAmpersand::Overlaps, and PostgreSQL’s
range/array && (deferred) would fold onto the same variant. Binds at the “any
other operator” precedence (the Contains rank), left-associative.
Distinct from Overlaps, the SQL-standard OVERLAPS keyword
period predicate over (start, end) rows — a different surface (keyword vs symbol),
operand shape (two-element rows vs scalars), and render (OVERLAPS vs &&).
JsonGet
PostgreSQL -> JSON access — object field / array element returned as
json/jsonb. Same “any other operator” precedence.
JsonGetText
PostgreSQL ->> JSON access — object field / array element returned as text,
the text-typed form of JsonGet. Same precedence.
JsonExists
PostgreSQL ? jsonb key/element existence — “does the right text string exist as
a top-level key (object) or array element (array) of the left jsonb?”. Binds at
PostgreSQL’s “any other operator” precedence (the Contains rank),
left-associative. Lexed only under OperatorSyntax::jsonb_operators; the ? byte
is otherwise a stray byte in PostgreSQL (it has no ? parameter) or the anonymous
placeholder elsewhere.
JsonExistsAny
PostgreSQL ?| jsonb any-key existence — “does any of the right text[] strings
exist as a top-level key/element of the left jsonb?”. Same “any other operator”
precedence as JsonExists.
JsonExistsAll
PostgreSQL ?& jsonb all-keys existence — “do all of the right text[] strings
exist as top-level keys/elements of the left jsonb?”. Same precedence.
JsonPathExists
PostgreSQL @? — “does the right jsonpath return any item for the left jsonb?”.
Same “any other operator” precedence.
JsonPathMatch
PostgreSQL @@ — the match operator: for jsonb @@ jsonpath it returns the result
of the JSON-path predicate check, and it is also the tsvector @@ tsquery full-text
search match. One operator key for the shared @@ spelling; same “any other operator”
precedence.
JsonExtractPath
PostgreSQL #> — extract the jsonb sub-object at the right text[] path, returned
as jsonb. Same “any other operator” precedence.
JsonExtractPathText
PostgreSQL #>> — extract the jsonb sub-object at the right text[] path, returned
as text, the text-typed form of JsonExtractPath. Same
precedence.
JsonDeletePath
PostgreSQL #- — delete the field/element of the left jsonb at the right text[]
path. Same “any other operator” precedence. The #- lexeme is munched over the two
contiguous bytes ahead of the bare # bitwise-XOR (engine-verified: 5#-3 is
5 #- 3, while a space splits it into # then -3).
BitwiseOr
Bitwise OR, spelled | (PostgreSQL, MySQL, SQLite, DuckDB). In PostgreSQL/SQLite/
DuckDB it shares one “bitwise” precedence with &/<</>> (between additive and
comparison); MySQL ranks it strictly looser than & (the load-bearing per-dialect
precedence split), so its binding power is dialect data
(BindingPowerTable::bitwise_or).
BitwiseAnd
Bitwise AND, spelled & (PostgreSQL, MySQL, SQLite, DuckDB). Shares the one bitwise
rank with |/<</>> in PostgreSQL/SQLite/DuckDB; binds tighter than | and
looser than the shifts in MySQL (dialect data, see
BindingPowerTable::bitwise_and).
BitwiseShiftLeft
Bitwise left shift, spelled << (PostgreSQL, MySQL, SQLite, DuckDB). Grouped with
BitwiseShiftRight at one shift rank in every dialect —
looser than additive everywhere (1 << 2 + 3 is 1 << (2 + 3), engine-measured on
SQLite/PG/DuckDB) — but that rank sits below additive and above & in MySQL
(dialect data,
BindingPowerTable::bitwise_shift).
BitwiseShiftRight
Bitwise right shift, spelled >> (PostgreSQL, MySQL, SQLite, DuckDB). The mirror of
BitwiseShiftLeft; same shift rank.
BitwiseXor(BitwiseXorSpelling)
Bitwise exclusive-or. Two dialect-disjoint spellings fold onto this one operator:
PostgreSQL’s # and MySQL’s ^. The BitwiseXorSpelling tag is
load-bearing for validity, not only fidelity — PostgreSQL rejects ^ as XOR (there
^ is exponentiation) and MySQL treats # as a comment — so a normalized render
would not re-parse under the dialect that produced it (the same contract
IsNotDistinctFrom keeps). The two spellings also bind
at different precedences: PostgreSQL’s # is an “any other operator” (looser than
additive), MySQL’s ^ binds tighter than * — dialect data on
BindingPowerTable::bitwise_xor.
Distinct from the logical Xor keyword operator (MySQL XOR).
Eq(EqualsSpelling)
Equality, spelled = everywhere and additionally == in SQLite. The two
spellings are one operator; the EqualsSpelling tag records
which the source used so it round-trips.
NotEq(NotEqSpelling)
Inequality, spelled <> (SQL-standard) everywhere and additionally !=
(C-style) in every bundled dialect. The two spellings are one operator; the
NotEqSpelling tag records which the source used so it round-trips.
Lt
< — less-than.
LtEq
<= — less-than-or-equal.
Gt
> — greater-than.
GtEq
>= — greater-than-or-equal.
IsDistinctFrom(IsDistinctFromSpelling)
The null-safe inequality predicate IS DISTINCT FROM (SQL:1999 T151): true when
the operands differ, treating NULL as an ordinary comparable value rather than
yielding NULL. The parser recognizes it in the IS predicate arm, not the
symbolic-operator loop. Binds at comparison precedence, non-associative like =
(PostgreSQL a_expr IS DISTINCT FROM a_expr %prec IS, gram.y). Two
interchangeable-semantics spellings fold onto it: the SQL:1999 IS DISTINCT FROM
keyword form and SQLite’s bare IS NOT (a IS NOT b, SQLite’s general negated
IS). The IsDistinctFromSpelling tag records which the source used so the
surface round-trips, mirroring the IsNotDistinctFrom
complement.
IsNotDistinctFrom(IsNotDistinctFromSpelling)
The complement of IsDistinctFrom: the null-safe
equality predicate, true when the operands are equal or both NULL. A distinct
operator key at the same comparison precedence. Two interchangeable-semantics
spellings fold onto it: the SQL:1999 IS NOT DISTINCT FROM keyword
form (which SQLite’s general IS also produces), recognized in the IS-predicate
arm; and MySQL’s <=> operator, recognized in the symbolic-operator loop. The
IsNotDistinctFromSpelling tag records which the source used. Unlike the other
spelling tags this is load-bearing for validity, not only fidelity: MySQL rejects
the keyword form and the other dialects reject <=>, so the spelling cannot be
normalized away without producing input the same dialect fails to re-parse.
Regexp(RegexpSpelling)
MySQL RLIKE / REGEXP regular-expression match. The two keywords are
synonyms folding onto one operator; the RegexpSpelling tag
records which the source used. Binds at comparison precedence (like LIKE).
Glob
SQLite’s GLOB pattern-match operator — case-sensitive Unix-glob matching
(*/?/[…]). A keyword infix operator (KeywordOperators::Sqlite), the
SQLite analogue of MySQL’s RLIKE. Binds at comparison precedence (like
LIKE/REGEXP).
Match
SQLite’s MATCH operator — a grammar hook whose meaning is supplied by an
application-defined function (FTS, R-Tree). A keyword infix operator
(KeywordOperators::Sqlite) sibling of Glob; binds at
comparison precedence. The bundled engine registers no match backing, so a
bare prepare rejects it — it is grammar-only, guarded by round-trip rather
than an accept/reject oracle.
Overlaps
The SQL-standard OVERLAPS period predicate (SQL:2016 F251): (s1, e1) OVERLAPS (s2, e2) — true when the two time periods, each given as a (start, end | duration) pair, share any instant. Both operands are exactly-two-element rows
(Expr::Row, bare parenthesized pair or ROW(...)), a shape the parser enforces
(a scalar, a single-element grouping, or a three-element row is a parse error,
matching PostgreSQL’s row OVERLAPS row production and its wrong-arity ereport).
The boolean result is not itself a row, so the predicate never chains
(x OVERLAPS y OVERLAPS z rejects) — modelled non-associative. Binds tighter than
the comparison operators (x OVERLAPS y = TRUE groups (x OVERLAPS y) = TRUE) and
looser than the arithmetic/Op rank, its own PostgreSQL %nonassoc OVERLAPS gram.y
row. Gated by
PredicateSyntax::overlaps_period_predicate.
And
AND — logical conjunction.
Xor
MySQL XOR logical exclusive-or. Binds between AND and OR in precedence.
Or
OR — logical disjunction.
Trait Implementations§
Source§impl Clone for BinaryOperator
impl Clone for BinaryOperator
Source§fn clone(&self) -> BinaryOperator
fn clone(&self) -> BinaryOperator
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BinaryOperator
impl Debug for BinaryOperator
Source§impl<'de> Deserialize<'de> for BinaryOperator
impl<'de> Deserialize<'de> for BinaryOperator
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for BinaryOperator
Source§impl Hash for BinaryOperator
impl Hash for BinaryOperator
Source§impl PartialEq for BinaryOperator
impl PartialEq for BinaryOperator
Source§impl Render for BinaryOperator
impl Render for BinaryOperator
Source§fn render(&self, ctx: &RenderCtx<'_>, f: &mut Formatter<'_>) -> Result
fn render(&self, ctx: &RenderCtx<'_>, f: &mut Formatter<'_>) -> Result
Source§fn operand_binding_power(&self) -> Option<BindingPower>
fn operand_binding_power(&self) -> Option<BindingPower>
None (the default) for a self-delimiting node — an atom, call, or
constructor — that never needs parentheses. Read more