I would like to query one of my models in a server script. I'm trying to use the Query object for this, however, I don't see a way to formulate the conditions within the given API. What I need can be expressed in a query language like this:
(FirstValue = :FirstValue or FirstValue = null) and (SecondValue = :SecondValue or SecondValue = null) and (ThirdValue = :ThirdValue or ThirdValue = null)
(The goal is to query a lookup table based on several values. In the lookup table, null
represents that this value isn't relevant and any value should be considered a match.)
The Query
class appears to support only and
by specifying more than one filter, but there's no clear way to express or
, is there? Or maybe there's a way to use the query language within the server script?
Using query script to fetch records in a UI element, reacting to onLoad
and processing them there is not an option.
I know some ways to achieve desired result:
then you can bind this query parameters to some widgets and load datasource on value change.
Important:
The "?" modifier for leaf operators considers a null value for the right-hand side of the expression to be true (Query Builder).