Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 40 additions & 1 deletion regress/expected/cypher_match.out
Original file line number Diff line number Diff line change
Expand Up @@ -2119,6 +2119,43 @@ SELECT * FROM cypher('cypher_match', $$MATCH ({n0:0}) MATCH ()-[]->() MATCH ({n1
---
(0 rows)

--
-- issue#945 : un-aliased match clauses should be included in output node
--
SELECT * from cypher('cypher_match', $$ CREATE (a:label1 {id: '1'}), (b:label1 {id: '2'})$$) as (a agtype);
a
---
(0 rows)

SELECT * from cypher('cypher_match', $$ CREATE (a:label2 {id: '1'}), (b:label2 {id: '2'})$$) as (a agtype);
a
---
(0 rows)

SELECT * from cypher('cypher_match', $$ MATCH (:label1) RETURN count(*) $$) as (result agtype);
result
--------
2
(1 row)

SELECT * from cypher('cypher_match', $$ MATCH (:label1),(:label2) RETURN count(*) $$) as (result agtype);
result
--------
4
(1 row)

SELECT * from cypher('cypher_match', $$ MATCH (a:label1),(:label2) RETURN count(*) $$) as (result agtype);
result
--------
4
(1 row)

SELECT * from cypher('cypher_match', $$ MATCH (:label1),(a:label2) RETURN count(*) $$) as (result agtype);
result
--------
4
(1 row)

--
-- self referencing property constraints (issue #898)
--
Expand Down Expand Up @@ -2178,7 +2215,7 @@ SELECT * FROM cypher('cypher_match', $$ CREATE () WITH * MATCH (x{n0:x.n1}) RETU
-- Clean up
--
SELECT drop_graph('cypher_match', true);
NOTICE: drop cascades to 17 other objects
NOTICE: drop cascades to 19 other objects
DETAIL: drop cascades to table cypher_match._ag_label_vertex
drop cascades to table cypher_match._ag_label_edge
drop cascades to table cypher_match.v
Expand All @@ -2196,6 +2233,8 @@ drop cascades to table cypher_match.other_v
drop cascades to table cypher_match.opt_match_v
drop cascades to table cypher_match.opt_match_e
drop cascades to table cypher_match.knows
drop cascades to table cypher_match.label1
drop cascades to table cypher_match.label2
NOTICE: graph "cypher_match" has been dropped
drop_graph
------------
Expand Down
11 changes: 11 additions & 0 deletions regress/sql/cypher_match.sql
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,17 @@ SELECT * FROM cypher('cypher_match', $$ MATCH (_age_default_whatever) RETURN 0 $
SELECT * FROM cypher('cypher_match', $$ MATCH ({name: "Dave"}) MATCH ({name: "Dave"}) MATCH ({name: "Dave"}) RETURN 0 $$) as (a agtype);
SELECT * FROM cypher('cypher_match', $$MATCH ({n0:0}) MATCH ()-[]->() MATCH ({n1:0})-[]-() RETURN 0 AS n2$$) as (a agtype);

--
-- issue#945 : un-aliased match clauses should be included in output node
--
SELECT * from cypher('cypher_match', $$ CREATE (a:label1 {id: '1'}), (b:label1 {id: '2'})$$) as (a agtype);
SELECT * from cypher('cypher_match', $$ CREATE (a:label2 {id: '1'}), (b:label2 {id: '2'})$$) as (a agtype);
SELECT * from cypher('cypher_match', $$ MATCH (:label1) RETURN count(*) $$) as (result agtype);
SELECT * from cypher('cypher_match', $$ MATCH (:label1),(:label2) RETURN count(*) $$) as (result agtype);
SELECT * from cypher('cypher_match', $$ MATCH (a:label1),(:label2) RETURN count(*) $$) as (result agtype);
SELECT * from cypher('cypher_match', $$ MATCH (:label1),(a:label2) RETURN count(*) $$) as (result agtype);


--
-- self referencing property constraints (issue #898)
--
Expand Down
5 changes: 3 additions & 2 deletions src/backend/parser/cypher_clause.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,10 @@
* 1. the node is in a path variable
* 2. the node is a variable
* 3. the node contains filter properties
* 4. the node has a valid label
*/
#define INCLUDE_NODE_IN_JOIN_TREE(path, node) \
(path->var_name || node->name || node->props)
(path->var_name || node->name || node->props || node->label )

typedef Query *(*transform_method)(cypher_parsestate *cpstate,
cypher_clause *clause);
Expand Down Expand Up @@ -3805,7 +3806,7 @@ static List *transform_match_entities(cypher_parsestate *cpstate, Query *query,
}

/* should we make the node available */
output_node = (special_VLE_case && !node->name && !node->props) ?
output_node = (special_VLE_case && !node->name && !node->props && !valid_label) ?
false :
INCLUDE_NODE_IN_JOIN_TREE(path, node);

Expand Down