Skip to main content

PartialComparisonExpression

@webda/ql


Class: PartialComparisonExpression<T>

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

A comparison expression that treats undefined attributes as a match in partial mode

When the builder is in partial mode and the target attribute is undefined, evaluation returns true and flags the result as a partial match.

Extends​

Type Parameters​

T​

T extends ComparisonOperator = ComparisonOperator

the specific comparison operator type

Constructors​

Constructor​

new PartialComparisonExpression<T>(builder, op, attribute, value): PartialComparisonExpression<T>

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

Parameters​

builder​

PartialExpressionBuilder

the partial expression builder (used to read partial mode flag)

op​

T

comparison operator

attribute​

string

dot-notation attribute path

value​

any

value to compare against

Returns​

PartialComparisonExpression<T>

Overrides​

ComparisonExpression.constructor

Properties​

attribute​

attribute: string[]

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

Attribute to read from the object (split by .)

Inherited from​

ComparisonExpression.attribute


builder​

protected builder: PartialExpressionBuilder

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

the partial expression builder (used to read partial mode flag)


operator​

operator: T

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

Inherited from​

ComparisonExpression.operator


value​

value: value | value[]

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

Right side of the comparison

Inherited from​

ComparisonExpression.value

Methods​

eval()​

eval(target): boolean

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

Override the eval to check if the attribute is present if not and we are in partial mode, return true

Parameters​

target​

any

the object to evaluate

Returns​

boolean

true if the target matches

Overrides​

ComparisonExpression.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

Inherited from​

ComparisonExpression.setAttributeValue


toString()​

toString(): string

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

Returns​

string

Inherited from​

ComparisonExpression.toString


toStringAttribute()​

toStringAttribute(): string

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

Allow subclass to create different display

Returns​

string

the attribute string

Inherited from​

ComparisonExpression.toStringAttribute


toStringOperator()​

toStringOperator(): T

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

Allow subclass to create different display

Returns​

T

the operator string

Inherited from​

ComparisonExpression.toStringOperator


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

Inherited from​

ComparisonExpression.toStringValue


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

Inherited from​

ComparisonExpression.getAttributeValue


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

Inherited from​

ComparisonExpression.likeToRegex