Use the ignore_if_null wrapper in your CQL to’filter out’null input values. This is a useful extension for creating user-designed searches.
{[], se_lt_x :: [a-UserName, b-ignore_if_null(SearchKey), ...]}
At runtime, if SearchKey is bound to a value other than {null} then
the query will contain WHERE ... b = ?
. If, however,
SearchKey is bound to {null}
, then this comparison will be
omitted.
Disjunctions
In general, don't use ignore_if_null in disjunctions. Consider this query:
SearchKey = '%ELSTON%', {[], se_lt_x :: [a-UserName, b-RealName], ( RealName =~ SearchKey ; UserName =~ SearchKey)}
The query means "find a user where the UserName contains ELSTON OR
the RealName contain ELSTON". If !SearchKey is {null} then RealName=~
{null}
will fail, which is correct. If ignore_if_null was used, the test would
succeed, which means the disjunction would always succeed i.e.
the query would contain no restriction, which is clearly not the
intended result. FIXME: Mike, what is this all about?