Skip to content

fix: Preserve explicit label constraints when binding already-scoped node variables#702

Merged
adsharma merged 1 commit into
mainfrom
fix/issue-696-label-constraint-reorder
Jul 18, 2026
Merged

fix: Preserve explicit label constraints when binding already-scoped node variables#702
adsharma merged 1 commit into
mainfrom
fix/issue-696-label-constraint-reorder

Conversation

@adsharma

Copy link
Copy Markdown
Contributor

When a node variable is already in scope from a wildcard pattern (no labels), and a subsequent comma-separated pattern adds an explicit label constraint, the constraint was lost because addEntries() was a no-op (the explicit label was already in the all-tables set). The label rewriter then pruned away the constraint based on relationship type compatibility.

Fix: replace entries instead of adding them when the existing node was created from a wildcard pattern (getOriginalLabels().empty()). This ensures that MATCH (n1), (n0:L3)<-[:T5]-(n1:L2) constrains n1 to L2 just like the equivalent MATCH (n0:L3)<-[:T5]-(n1:L2), (n1).

Fixes #696.

…oped node variables

When a node variable is already in scope from a wildcard pattern (no labels),
and a subsequent comma-separated pattern adds an explicit label constraint,
the constraint was lost because addEntries() was a no-op (the explicit label
was already in the all-tables set). The label rewriter then pruned away the
constraint based on relationship type compatibility.

Fix: replace entries instead of adding them when the existing node was created
from a wildcard pattern (getOriginalLabels().empty()). This ensures that
MATCH (n1), (n0:L3)<-[:T5]-(n1:L2) constrains n1 to L2 just like the
equivalent MATCH (n0:L3)<-[:T5]-(n1:L2), (n1).

Fixes #696.
@adsharma
adsharma merged commit 4130790 into main Jul 18, 2026
4 checks passed
@adsharma
adsharma deleted the fix/issue-696-label-constraint-reorder branch July 18, 2026 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Reordering comma-separated MATCH patterns can ignore a label constraint on a previously bound variable

1 participant