feat(cypher): coalesce(var.prop, literal) in WHERE clauses#1034
Merged
Conversation
DeusData
enabled auto-merge
July 11, 2026 17:09
The WHERE parser rejected coalesce() outright ('unexpected operator'),
blocking null-safe numeric filters over optional graph properties —
the exact audit-query shape from the report:
MATCH (f:Function) WHERE coalesce(f.transitive_loop_depth, 0) >= 2
RETURN-side coalesce already worked; only the WHERE leaf lacked it.
Implementation: the condition leaf gains a coalesce_default literal.
The operator/value tail of condition parsing is factored into a shared
parse_condition_op so both subjects (var[.prop] and
coalesce(var.prop, literal)) accept the full operator set (comparisons,
IS [NOT] NULL, IN). At eval time a missing/empty property value is
substituted with the default before the operator runs. Supported form
is coalesce(var.prop, literal) — matching openCypher's two-argument
null-substitution for this subset.
Reproduce-first: cypher_exec_where_coalesce_issue874 runs the
reporter's exact query — RED (rc=-1 parse error) on the old parser —
and pins both directions: a failing default excludes property-less
nodes, a passing default includes them.
Closes #874
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #874.
WHERE coalesce(f.transitive_loop_depth, 0) >= 2— the reporter's exact null-safe audit filter — parsed with 'unexpected operator'. RETURN-sidecoalescealready existed; the WHERE leaf now supports it too.Design: the condition leaf carries an optional
coalesce_defaultliteral; the operator/value tail is factored into a sharedparse_condition_op, so the coalesce subject accepts the full operator set (comparisons,IS [NOT] NULL,IN) identically to a barevar.prop. Eval substitutes the default for missing/empty property values — real openCypher two-arg null-substitution semantics, not a rewrite trick.Reproduce-first: the reporter's query is the test — RED (
rc=-1) on the old parser; GREEN pins both directions (failing default excludes property-less nodes, passing default includes them).Full suite 5,997/0, lint-ci clean.