Skip to main content

CompOperator

Abstract base for every two-operand comparison operator — Eq, Ne, Gt, Gte, Lt, Lte, Between, In, Like, ILike, Is, Exists, and Match all extend it (directly or through one of those). Extends Operator. Useful mainly as the type to target when writing a SerializerExtension that needs to intercept every comparison, or when building a custom operator of your own.

Constructor

CompOperator(left: string | SqlElement, right?: any): CompOperator
new CompOperator(left: string | SqlElement, right?: any): CompOperator

Dual-callable. A string left must match <field>[\[\]] (a field-name expression with an optional trailing [] marking it an array field) — otherwise throws a TypeError ("is not a valid expression definition"). right is stored as-is; concrete subclasses set _symbol (the rendered operator keyword, e.g. '=', '>', 'like') and _operatorType themselves.

Properties

KeyTypeReadonlyDescription
_typeSerializationType.COMPARISON_EXPRESSIONYesDiscriminates this node during serialization.
_leftSqlElement | stringNoThe left-hand operand (a bare field name string, or an SQL element).
_rightanyNoThe right-hand operand — a literal, Param, Raw, sub-Select, or (for Between/In) an array.
_symbolstring | undefinedNoThe rendered operator keyword, set by each concrete subclass.
_isArrayboolean | undefinedNoSet when left was given as a string with a trailing [].

Plus _operatorType inherited from Operator.

Methods

_serialize()

_serialize(ctx: SerializeContext): string

Resolves both operands through the active SerializeContext — including, when generate({ strictParams: true }) is in effect, converting an inline literal right into an auto-generated bind parameter — and renders <left> <symbol> <right> via __defaultSerialize(). You normally don't call this directly; it runs as part of the owning query's .generate(). See Raw SQL and Parameters for strictParams.

See also