SetterValidator
Class: SetterValidator
Defined in: packages/ql/src/query.ts:1602
A query validator that operates in assignment mode
Instead of filtering objects, it assigns values to object properties.
Only supports = (assignment) combined with AND. No comparisons, OR, or other operators.
Protects against prototype pollution by ignoring __proto__ attributes.
Example
const target: any = {};
new SetterValidator('name = "John" AND age = 30').eval(target);
// target = { name: "John", age: 30 }
Throws
if non-assignment operators or OR expressions are used
Extends
Constructors
Constructor
new SetterValidator(
sql):SetterValidator
Defined in: packages/ql/src/query.ts:1607
Parameters
sql
string
assignment expression (e.g. 'field = "value" AND other = 10')
Returns
SetterValidator
Throws
if the expression contains non-assignment operators
Overrides
Properties
builder
protectedbuilder:ExpressionBuilder
Defined in: packages/ql/src/query.ts:1415
Inherited from
lexer
protectedlexer:WebdaQLLexer
Defined in: packages/ql/src/query.ts:1412
Inherited from
query
protectedquery:Query
Defined in: packages/ql/src/query.ts:1414
Inherited from
sql
protectedsql:string
Defined in: packages/ql/src/query.ts:1425
the query string to parse
Inherited from
tree
protectedtree:WebdaqlContext
Defined in: packages/ql/src/query.ts:1413
Inherited from
Methods
assign()
assign(
target,expression):void
Defined in: packages/ql/src/query.ts:1633
Recursively walk the expression tree and apply assignments
Parameters
target
any
object to assign values to
expression
must be an AndExpression or a = ComparisonExpression
Returns
void
Throws
if any non-assignment expression is encountered
displayTree()
displayTree(
tree?):string
Defined in: packages/ql/src/query.ts:1568
Display parse tree back as query
Parameters
tree?
ParseTree = ...
the parse tree to display
Returns
string
the query string representation
Inherited from
eval()
eval(
target):boolean
Defined in: packages/ql/src/query.ts:1619
Apply the assignments to the target object
Parameters
target
any
object to assign values to (mutated in place)
Returns
boolean
always true
Overrides
getExpression()
getExpression():
Expression
Defined in: packages/ql/src/query.ts:1531
Get the filter expression (without LIMIT / OFFSET / ORDER BY)
Returns
the filter expression
Inherited from
getLimit()
getLimit():
number
Defined in: packages/ql/src/query.ts:1523
Get parsed LIMIT value, defaulting to 1000
Returns
number
the limit value
Inherited from
getOffset()
getOffset():
string
Defined in: packages/ql/src/query.ts:1440
Get parsed OFFSET continuation token, or empty string if none
Returns
string
the offset token
Inherited from
getQuery()
getQuery():
Query
Defined in: packages/ql/src/query.ts:1539
Retrieve the full parsed query including filter, limit, offset, and orderBy
Returns
the full query object
Inherited from
hasCondition()
hasCondition():
boolean
Defined in: packages/ql/src/query.ts:1450
Check whether the query has a non-empty filter condition
An empty AND expression (no children) is considered to have no condition.
Returns
boolean
true if there is a filter condition
Inherited from
isDynamic()
isDynamic():
boolean
Defined in: packages/ql/src/query.ts:1559
Check whether this query's filter contains any dynamic values
Returns
boolean
true if any child comparison holds a DynamicValue
Inherited from
merge()
merge(
query?,type?):this
Defined in: packages/ql/src/query.ts:1479
Merge another query string into this query
Filter expressions are combined using the specified logical operator. LIMIT, OFFSET, and ORDER BY from the merged query override existing values.
Parameters
query?
string = ""
query string to merge in
type?
"AND" | "OR" = "AND"
logical operator to combine filters ("AND" or "OR")
Returns
this
this for chaining
Inherited from
toString()
toString():
string
Defined in: packages/ql/src/query.ts:1465
Reconstruct the query string from the parsed AST
Includes filter, ORDER BY, LIMIT, and OFFSET clauses.
Returns
string
the reconstructed query string