Skip to main content

ComparisonExpression

@webda/ql


Class: ComparisonExpression<T>

Defined in: packages/ql/src/query.ts:917

A leaf expression comparing an object attribute against a literal value

Supports dot-notation for nested attribute access (e.g. user.profile.name).

Extends​

Extended by​

Type Parameters​

T​

T extends ComparisonOperator = ComparisonOperator

the specific comparison operator type

Constructors​

Constructor​

new ComparisonExpression<T>(operator, attribute, rawValue): ComparisonExpression<T>

Defined in: packages/ql/src/query.ts:931

Parameters​

operator​

T

comparison operator

attribute​

string

dot-notation path to the object property (e.g. "user.name")

rawValue​

any[] | DynamicValue | value | null

literal value, DynamicValue, or array of values (for IN operator) to compare against

Returns​

ComparisonExpression<T>

Overrides​

Expression.constructor

Properties​

attribute​

attribute: string[]

Defined in: packages/ql/src/query.ts:925

Attribute to read from the object (split by .)


operator​

operator: T

Defined in: packages/ql/src/query.ts:866

Inherited from​

Expression.operator


rawValue​

rawValue: DynamicValue | value | DynamicValue | value[] | null

Defined in: packages/ql/src/query.ts:921

Right side of the comparison (raw parsed value, possibly DynamicValue)

Accessors​

value​

Get Signature​

get value(): value | value[] | null

Defined in: packages/ql/src/query.ts:941

Resolved value at evaluation time

Returns​

value | value[] | null

the resolved scalar or array value

Set Signature​

set value(val): void

Defined in: packages/ql/src/query.ts:955

Set the raw value

Parameters​
val​

DynamicValue | value | DynamicValue | value[] | null

new value

Returns​

void

Methods​

eval()​

eval(target): boolean

Defined in: packages/ql/src/query.ts:1041

Parameters​

target​

any

Returns​

boolean

Overrides​

Expression.eval


isDynamic()​

isDynamic(): boolean

Defined in: packages/ql/src/query.ts:962

Returns​

boolean

Overrides​

Expression.isDynamic


setAttributeValue()​

setAttributeValue(target): void

Defined in: packages/ql/src/query.ts:1024

Set the value of the attribute based on the assignment

If used as a Set expression

Parameters​

target​

any

the object to assign to

Returns​

void


toString()​

toString(): string

Defined in: packages/ql/src/query.ts:1133

Returns​

string

Overrides​

Expression.toString


toStringAttribute()​

toStringAttribute(): string

Defined in: packages/ql/src/query.ts:1118

Allow subclass to create different display

Returns​

string

the attribute string


toStringOperator()​

toStringOperator(): T

Defined in: packages/ql/src/query.ts:1126

Allow subclass to create different display

Returns​

T

the operator string


toStringValue()​

toStringValue(value): string

Defined in: packages/ql/src/query.ts:1098

Serialize a value to its WebdaQL string representation

Strings are double-quoted, booleans are uppercased, arrays are bracket-wrapped. Dynamic values serialize to their canonical function call string (e.g. NOW('-10m')).

Parameters​

value​

DynamicValue | value | DynamicValue | value[] | null

the value to serialize

Returns​

string

the serialized string


getAttributeValue()​

static getAttributeValue(target, attribute): any

Defined in: packages/ql/src/query.ts:1010

Traverse an object using a dot-notation attribute path

Parameters​

target​

any

object to read from

attribute​

string[]

path segments (e.g. ["user", "profile", "name"])

Returns​

any

the resolved value, or undefined if any segment is missing


likeToRegex()​

static likeToRegex(like): RegExp

Defined in: packages/ql/src/query.ts:983

Convert a SQL LIKE pattern to a JavaScript RegExp

  • % matches zero or more characters
  • _ matches exactly one character
  • \% and \_ are literal percent/underscore
  • Common regex metacharacters are escaped

Parameters​

like​

string

SQL LIKE pattern string

Returns​

RegExp

compiled RegExp