Skip to main content

BinaryOperator

Enum BinaryOperator 

Source
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

Source§

fn clone(&self) -> BinaryOperator

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 Debug for BinaryOperator

Source§

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

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

impl<'de> Deserialize<'de> for BinaryOperator

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for BinaryOperator

Source§

impl Hash for BinaryOperator

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for BinaryOperator

Source§

fn eq(&self, other: &BinaryOperator) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Render for BinaryOperator

Source§

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

Return the render for this value.
Source§

fn operand_binding_power(&self) -> Option<BindingPower>

The binding power this node contributes when it appears as an operand, or None (the default) for a self-delimiting node — an atom, call, or constructor — that never needs parentheses. Read more
Source§

impl Serialize for BinaryOperator

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for BinaryOperator

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> RenderExt for T
where T: Render,

Source§

fn displayed<'a>(&'a self, ctx: &'a RenderCtx<'a>) -> Displayed<'a, T>

Pair this node with an explicit canonical RenderCtx so format!, to_string, and {} render it. This is the canonical path: the ctx’s resolver and source must match the node’s parse.
Source§

fn debug_sql<'a>(&'a self, resolver: &'a dyn Resolver) -> DebugSql<'a, Self>
where Self: Sized,

Render this node for debugging against an explicitly-supplied resolver (the debug-SQL mitigation), returning a Display adapter. Read more
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.