SetterValidator
Class: SetterValidator
Defined in: packages/ql/src/query.ts:1096
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:1101
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:915
Inherited from
lexer
protectedlexer:WebdaQLLexer
Defined in: packages/ql/src/query.ts:912
Inherited from
query
protectedquery:Query
Defined in: packages/ql/src/query.ts:914
Inherited from
sql
protectedsql:string
Defined in: packages/ql/src/query.ts:925
the query string to parse
Inherited from
tree
protectedtree:WebdaqlContext
Defined in: packages/ql/src/query.ts:913
Inherited from
Methods
assign()
assign(
target,expression):void
Defined in: packages/ql/src/query.ts:1127
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:1062
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:1113
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:1032
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:1024
Get parsed LIMIT value, defaulting to 1000
Returns
number
the limit value
Inherited from
getOffset()
getOffset():
string
Defined in: packages/ql/src/query.ts:940
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:1040
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:950
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
merge()
merge(
query,type?):this
Defined in: packages/ql/src/query.ts:989
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"
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:965
Reconstruct the query string from the parsed AST
Includes filter, ORDER BY, LIMIT, and OFFSET clauses.
Returns
string
the reconstructed query string