codeql-cli-binaries
codeql-cli-binaries copied to clipboard
Suggestion: `boolean(<formula>)` expression
Especially when debugging queries it can often be interesting to know whether a predicate (or a relation) holds or not. However, you can only use expressions in result sets, requiring you to manually get a boolean value for the predicate in question, e.g.:
import java
from Method m, boolean isStatic
where
if m.isStatic() then isStatic = true
else isStatic = false
select m, isStatic
Therefore it might be useful to introduce a boolean(<formula>) expression. If the formula holds, then the result is true, otherwise false:
import java
from Method m
select m, boolean(m.isStatic())
Thanks for the suggestion; I've wanted this myself a few times. I've handed this over to the product team to consider for a future update.