PartialExpressionBuilder
Class: PartialExpressionBuilder
Defined in: packages/ql/src/query.ts:1236
Expression builder that creates PartialComparisonExpression nodes instead of regular ComparisonExpression nodes
Used by PartialValidator to support partial object matching.
Extends
Constructors
Constructor
new PartialExpressionBuilder():
PartialExpressionBuilder
Returns
PartialExpressionBuilder
Inherited from
Properties
limit
limit:
number
Defined in: packages/ql/src/query.ts:122
Parsed LIMIT value, if present
Inherited from
offset
offset:
string
Defined in: packages/ql/src/query.ts:126
Parsed OFFSET continuation token, if present
Inherited from
orderBy
orderBy:
OrderBy[]
Defined in: packages/ql/src/query.ts:130
Parsed ORDER BY clauses, if present
Inherited from
partial
partial:
boolean
Defined in: packages/ql/src/query.ts:1240
Whether partial mode is active (undefined attributes treated as matching)
partialMatch
partialMatch:
boolean
Defined in: packages/ql/src/query.ts:1244
Set to true during evaluation if any attribute was undefined and skipped
Methods
aggregateResult()
protectedaggregateResult(aggregate,nextResult):Query
Defined in: node_modules/.pnpm/antlr4ts@0.5.0-alpha.4/node_modules/antlr4ts/tree/AbstractParseTreeVisitor.d.ts:77
Aggregates the results of visiting multiple children of a node. After
either all children are visited or #shouldVisitNextChild returns
false, the aggregate value is returned as the result of
#visitChildren.
The default implementation returns nextResult, meaning
#visitChildren will return the result of the last child visited
(or return the initial value if the node has no children).
Parameters
aggregate
The previous aggregate value. In the default
implementation, the aggregate value is initialized to
#defaultResult, which is passed as the aggregate argument
to this method after the first child node is visited.
nextResult
The result of the immediately preceeding call to visit a child node.
Returns
The updated aggregate result.
Inherited from
ExpressionBuilder.aggregateResult
defaultResult()
protecteddefaultResult():Query
Defined in: packages/ql/src/query.ts:136
Default result when no expression is matched (empty AND, always true)
Returns
an empty AND query
Inherited from
ExpressionBuilder.defaultResult
getComparison()
getComparison(
ctx):any[]
Defined in: packages/ql/src/query.ts:247
Recursively flatten nested logical expressions of the same type
ANTLR produces right-recursive trees like a AND (b AND (c AND d)).
This method flattens them into [a, b, c, d] so a single LogicalExpression
holds all children at one level.
Parameters
ctx
AndLogicExpressionContext | OrLogicExpressionContext
an AND or OR logical expression context
Returns
any[]
flat array of child parse tree nodes
Inherited from
ExpressionBuilder.getComparison
getLimit()
getLimit():
number
Defined in: packages/ql/src/query.ts:155
Get parsed LIMIT value
Returns
number
the limit value
Inherited from
getOffset()
getOffset():
string
Defined in: packages/ql/src/query.ts:147
Get parsed OFFSET continuation token
Returns
string
the offset token
Inherited from
setPartial()
setPartial(
partial):void
Defined in: packages/ql/src/query.ts:1250
Enable or disable partial evaluation mode
Parameters
partial
boolean
whether to enable partial mode
Returns
void
setPartialMatch()
setPartialMatch(
partial):void
Defined in: packages/ql/src/query.ts:1258
Set the partial match flag (reset before each evaluation)
Parameters
partial
boolean
the partial match flag value
Returns
void
shouldVisitNextChild()
protectedshouldVisitNextChild(node,currentResult):boolean
Defined in: node_modules/.pnpm/antlr4ts@0.5.0-alpha.4/node_modules/antlr4ts/tree/AbstractParseTreeVisitor.d.ts:102
This method is called after visiting each child in
#visitChildren. This method is first called before the first
child is visited; at that point currentResult will be the initial
value (in the default implementation, the initial value is returned by a
call to #defaultResult. This method is not called after the last
child is visited.
The default implementation always returns true, indicating that
visitChildren should only return after all children are visited.
One reason to override this method is to provide a "short circuit"
evaluation option for situations where the result of visiting a single
child has the potential to determine the result of the visit operation as
a whole.
Parameters
node
RuleNode
The RuleNode whose children are currently being visited.
currentResult
The current aggregate result of the children visited to the current point.
Returns
boolean
true to continue visiting children. Otherwise return
false to stop visiting children and immediately return the
current aggregate result from #visitChildren.
Inherited from
ExpressionBuilder.shouldVisitNextChild
visit()
visit(
tree):Query
Defined in: node_modules/.pnpm/antlr4ts@0.5.0-alpha.4/node_modules/antlr4ts/tree/AbstractParseTreeVisitor.d.ts:17
The default implementation calls ParseTree#accept on the specified tree.
Parameters
tree
ParseTree
Returns
Inherited from
visitAndLogicExpression()
visitAndLogicExpression(
ctx):Expression
Defined in: packages/ql/src/query.ts:278
Get the AndExpression, regrouping all the parameters
By default the parser is doing a AND (b AND (c AND d)) creating 3 depth expressions This visitor simplify to a AND b AND c AND d with only one Expression
Parameters
ctx
AndLogicExpressionContext
the AND logic expression context
Returns
the flattened AndExpression
Inherited from
ExpressionBuilder.visitAndLogicExpression
visitAtomExpression()
visitAtomExpression(
ctx):Expression
Defined in: packages/ql/src/query.ts:377
A bare atom used as an expression: only TRUE / FALSE are valid
Parameters
ctx
AtomExpressionContext
the atom expression context
Returns
the constant expression
Throws
for identifiers, numbers and strings
Inherited from
ExpressionBuilder.visitAtomExpression
visitBinaryComparisonExpression()
visitBinaryComparisonExpression(
ctx):PartialComparisonExpression<any>
Defined in: packages/ql/src/query.ts:1278
Visit a binary comparison, returning a PartialComparisonExpression
Parameters
ctx
any
the binary comparison context
Returns
PartialComparisonExpression<any>
the partial comparison expression
Overrides
ExpressionBuilder.visitBinaryComparisonExpression
visitBooleanLiteral()
visitBooleanLiteral(
ctx):boolean
Defined in: packages/ql/src/query.ts:399
Read the boolean literal
Parameters
ctx
BooleanLiteralContext
the boolean literal context
Returns
boolean
the boolean value
Inherited from
ExpressionBuilder.visitBooleanLiteral
visitChildren()
visitChildren(
node):Query
Defined in: node_modules/.pnpm/antlr4ts@0.5.0-alpha.4/node_modules/antlr4ts/tree/AbstractParseTreeVisitor.d.ts:33
The default implementation initializes the aggregate result to
#defaultResult defaultResult(). Before visiting each child, it
calls #shouldVisitNextChild shouldVisitNextChild; if the result
is false no more children are visited and the current aggregate
result is returned. After visiting a child, the aggregate result is
updated by calling #aggregateResult aggregateResult with the
previous aggregate result and the result of visiting the child.
The default implementation is not safe for use in visitors that modify the tree structure. Visitors that modify the tree should override this method to behave properly in respect to the specific algorithm in use.
Parameters
node
RuleNode
Returns
Inherited from
ExpressionBuilder.visitChildren
visitContainsExpression()
visitContainsExpression(
ctx):PartialComparisonExpression<"CONTAINS">
Defined in: packages/ql/src/query.ts:1300
Visit a CONTAINS expression, returning a PartialComparisonExpression
Parameters
ctx
any
the CONTAINS expression context
Returns
PartialComparisonExpression<"CONTAINS">
the partial comparison expression
Overrides
ExpressionBuilder.visitContainsExpression
visitErrorNode()
visitErrorNode(
node):Query
Defined in: node_modules/.pnpm/antlr4ts@0.5.0-alpha.4/node_modules/antlr4ts/tree/AbstractParseTreeVisitor.d.ts:47
The default implementation returns the result of #defaultResult defaultResult.
Parameters
node
ErrorNode
Returns
Inherited from
ExpressionBuilder.visitErrorNode
visitInExpression()
visitInExpression(
ctx):PartialComparisonExpression<"IN">
Defined in: packages/ql/src/query.ts:1289
Visit an IN expression, returning a PartialComparisonExpression
Parameters
ctx
any
the IN expression context
Returns
PartialComparisonExpression<"IN">
the partial comparison expression
Overrides
ExpressionBuilder.visitInExpression
visitIntegerLiteral()
visitIntegerLiteral(
ctx):number
Defined in: packages/ql/src/query.ts:408
Read the number literal
Parameters
ctx
IntegerLiteralContext
the integer literal context
Returns
number
the parsed integer value
Inherited from
ExpressionBuilder.visitIntegerLiteral
visitIsNotNullExpression()
visitIsNotNullExpression(
ctx):PartialComparisonExpression<"IS NOT NULL">
Defined in: packages/ql/src/query.ts:1320
Visit an IS NOT NULL expression, returning a PartialComparisonExpression
Parameters
ctx
any
the IS NOT NULL expression context
Returns
PartialComparisonExpression<"IS NOT NULL">
the partial comparison expression
Overrides
ExpressionBuilder.visitIsNotNullExpression
visitIsNullExpression()
visitIsNullExpression(
ctx):PartialComparisonExpression<"IS NULL">
Defined in: packages/ql/src/query.ts:1311
Visit an IS NULL expression, returning a PartialComparisonExpression
Parameters
ctx
any
the IS NULL expression context
Returns
PartialComparisonExpression<"IS NULL">
the partial comparison expression
Overrides
ExpressionBuilder.visitIsNullExpression
visitLikeExpression()
visitLikeExpression(
ctx):PartialComparisonExpression<"LIKE">
Defined in: packages/ql/src/query.ts:1267
Visit a LIKE expression, returning a PartialComparisonExpression
Parameters
ctx
any
the LIKE expression context
Returns
PartialComparisonExpression<"LIKE">
the partial comparison expression
Overrides
ExpressionBuilder.visitLikeExpression
visitLimitExpression()
visitLimitExpression(
ctx):void
Defined in: packages/ql/src/query.ts:163
Visit a LIMIT clause and store the integer value
Parameters
ctx
LimitExpressionContext
the limit expression context
Returns
void
Inherited from
ExpressionBuilder.visitLimitExpression
visitNumberLiteral()
visitNumberLiteral(
ctx):number
Defined in: packages/ql/src/query.ts:417
Read a signed or decimal number literal
Parameters
ctx
NumberLiteralContext
the number literal context
Returns
number
the parsed number
Inherited from
ExpressionBuilder.visitNumberLiteral
visitOffsetExpression()
visitOffsetExpression(
ctx):void
Defined in: packages/ql/src/query.ts:171
Visit an OFFSET clause and store the string continuation token
Parameters
ctx
OffsetExpressionContext
the offset expression context
Returns
void
Inherited from
ExpressionBuilder.visitOffsetExpression
visitOrderExpression()
visitOrderExpression(
ctx):void
Defined in: packages/ql/src/query.ts:191
Read the order by values
Parameters
ctx
OrderExpressionContext
the order expression context
Returns
void
Inherited from
ExpressionBuilder.visitOrderExpression
visitOrderFieldExpression()
visitOrderFieldExpression(
ctx):OrderBy
Defined in: packages/ql/src/query.ts:180
Visit a order field expression
Parameters
ctx
OrderFieldExpressionContext
the order field expression context
Returns
the parsed OrderBy
Inherited from
ExpressionBuilder.visitOrderFieldExpression
visitOrLogicExpression()
visitOrLogicExpression(
ctx):Expression
Defined in: packages/ql/src/query.ts:364
Get the OrExpression, regrouping all the parameters
By default the parser is doing a OR (b OR (c OR d)) creating 3 depth expressions This visitor simplify to a OR b OR c OR d with only one Expression
Parameters
ctx
OrLogicExpressionContext
the OR logic expression context
Returns
the flattened OrExpression
Inherited from
ExpressionBuilder.visitOrLogicExpression
visitParameter()
visitParameter(
ctx):never
Defined in: packages/ql/src/query.ts:426
A ? or :name placeholder reaching evaluation was never bound
Parameters
ctx
ParameterContext
the parameter context
Returns
never
Throws
always: use bind() or pass the parameters to query()
Inherited from
ExpressionBuilder.visitParameter
visitSetExpression()
visitSetExpression(
ctx):value[]
Defined in: packages/ql/src/query.ts:301
Visit each value of the [..., ..., ...] set
Parameters
ctx
SetExpressionContext
the set expression context
Returns
value[]
the array of values
Inherited from
ExpressionBuilder.visitSetExpression
visitStringLiteral()
visitStringLiteral(
ctx):string
Defined in: packages/ql/src/query.ts:390
Read a string literal, stripping the surrounding single or double quotes
Parameters
ctx
StringLiteralContext
the string literal context
Returns
string
the unquoted string value
Inherited from
ExpressionBuilder.visitStringLiteral
visitTerminal()
visitTerminal(
node):Query
Defined in: node_modules/.pnpm/antlr4ts@0.5.0-alpha.4/node_modules/antlr4ts/tree/AbstractParseTreeVisitor.d.ts:40
The default implementation returns the result of #defaultResult defaultResult.
Parameters
node
TerminalNode
Returns
Inherited from
ExpressionBuilder.visitTerminal
visitWebdaql()
visitWebdaql(
ctx):Query
Defined in: packages/ql/src/query.ts:205
Visit the root webdaql rule and build the complete Query
Parses filter expression, ORDER BY, LIMIT, and OFFSET clauses. Returns an empty AND expression (always true) when no filter is present.
Parameters
ctx
WebdaqlContext
the webdaql parse context
Returns
the built Query