-
Notifications
You must be signed in to change notification settings - Fork 473
Fix MATCH on brand-new label after CREATE returning 0 rows #2341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1492,6 +1492,56 @@ $$) AS (val agtype); | |||||||||||||||||||
|
|
||||||||||||||||||||
| SELECT drop_graph('issue_2308', true); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| -- | ||||||||||||||||||||
| -- Issue 2193: CREATE ... WITH ... MATCH on brand-new label returns 0 rows | ||||||||||||||||||||
| -- on first execution because match_check_valid_label() runs before | ||||||||||||||||||||
| -- transform_prev_cypher_clause() creates the label table. | ||||||||||||||||||||
| -- | ||||||||||||||||||||
| SELECT create_graph('issue_2193'); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| -- Reporter's exact case: CREATE two Person nodes, then MATCH on Person | ||||||||||||||||||||
| -- Should return 2 rows on the very first execution | ||||||||||||||||||||
| SELECT * FROM cypher('issue_2193', $$ | ||||||||||||||||||||
| CREATE (a:Person {name: 'Jane', livesIn: 'London'}), | ||||||||||||||||||||
| (b:Person {name: 'Tom', livesIn: 'Copenhagen'}) | ||||||||||||||||||||
| WITH a, b | ||||||||||||||||||||
| MATCH (p:Person) | ||||||||||||||||||||
| RETURN p.name ORDER BY p.name | ||||||||||||||||||||
| $$) AS (result agtype); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| -- Single CREATE + MATCH on brand-new label | ||||||||||||||||||||
| SELECT * FROM cypher('issue_2193', $$ | ||||||||||||||||||||
| CREATE (a:City {name: 'Berlin'}) | ||||||||||||||||||||
| WITH a | ||||||||||||||||||||
| MATCH (c:City) | ||||||||||||||||||||
| RETURN c.name | ||||||||||||||||||||
| $$) AS (result agtype); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| -- MATCH on a label that now exists (second execution) still works | ||||||||||||||||||||
| SELECT * FROM cypher('issue_2193', $$ | ||||||||||||||||||||
| CREATE (a:City {name: 'Paris'}) | ||||||||||||||||||||
| WITH a | ||||||||||||||||||||
| MATCH (c:City) | ||||||||||||||||||||
| RETURN c.name ORDER BY c.name | ||||||||||||||||||||
| $$) AS (result agtype); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| -- MATCH on non-existent label without DML predecessor still returns 0 rows | ||||||||||||||||||||
| SELECT * FROM cypher('issue_2193', $$ | ||||||||||||||||||||
| MATCH (x:NonExistentLabel) | ||||||||||||||||||||
| RETURN x | ||||||||||||||||||||
| $$) AS (result agtype); | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
||||||||||||||||||||
| -- MATCH on non-existent label after DML predecessor still returns 0 rows | |
| SELECT * FROM cypher('issue_2193', $$ | |
| CREATE (a:Person {name: 'Alice'}) | |
| WITH a | |
| MATCH (p:NonExistentLabel) | |
| RETURN p | |
| $$) AS (result agtype); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The regression tests added for issue_2193 assert a specific row order (e.g., Jane then Tom; Berlin then Paris) but the Cypher queries don't include an ORDER BY. Without ordering, result order can vary with plan changes (seq scan order, optimizer choices), making the test output potentially flaky. Consider adding an ORDER BY on the returned expression (or changing assertions to use counts/sets) to make the expected output deterministic.