Hello,
I use BaseX mostly for boolean queries, I have a hardware database and
I check if specific hardware support features I need.
It works great but when something is not as expected, it's hard to find
out the reason.
E.g. given an expression like:
$some-value = $some-list and (custom:predicate() or $x > $y)
I would like to know why it's true or false.
For now I add trace() manually on the subexpressions, rerun, add trace
to more specific parts, etc.
Ideally I would want to break down the query execution so it shows the
values of subparts of the query to pinpoint why it is false, e.g. have
an output like:
$some-value = $some-list and (custom:predicate() or $x > $y) ->
false()$some-value = $some-list -> true()$some-value -> 1$some-list ->
(1, 2, ..., 10)custom:predicate() or $x > $y ->
false()custom:predicate() -> false()... # It should also go inside the
function$x > $y -> false()$x -> 10$y -> 11
Any ideas how it could be achieved?
Looking at the code, maybe a debug() (like iter() or item()) method
could be added to Expr objects which would trace the expression query,
file, line and the result of the expression (or probably the first x
characters of the result to avoid huge output)? With an xquery function
which would trigger it.
I also thought of modifying the query programmatically to add trace()
calls but that seems overly complicated.
Best regards,
Iwan