Skip to main content

ComparisonExpression

@webda/ql


Class: ComparisonExpression<T>

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

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, value): ComparisonExpression<T>

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

Parameters​

operator​

T

comparison operator

attribute​

string

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

value​

any[] | value

literal value 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:518

Attribute to read from the object (split by .)


operator​

operator: T

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

Inherited from​

Expression.operator


value​

value: value | value[]

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

Right side of the comparison

Methods​

eval()​

eval(target): boolean

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

Parameters​

target​

any

Returns​

boolean

Overrides​

Expression.eval


setAttributeValue()​

setAttributeValue(target): void

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

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:677

Returns​

string

Overrides​

Expression.toString


toStringAttribute()​

toStringAttribute(): string

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

Allow subclass to create different display

Returns​

string

the attribute string


toStringOperator()​

toStringOperator(): T

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

Allow subclass to create different display

Returns​

T

the operator string


toStringValue()​

toStringValue(value): string

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

Serialize a value to its WebdaQL string representation

Strings are double-quoted, booleans are uppercased, arrays are bracket-wrapped.

Parameters​

value​

value | value[]

the value to serialize

Returns​

string

the serialized string


getAttributeValue()​

static getAttributeValue(target, attribute): any

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

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:541

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