jrgemignani commented on issue #330:
URL: https://github.com/apache/age/issues/330#issuecomment-1282936299
The following -
`CREATE (a:A {foo:1})-[:incs]->(:C), (a)-[:incs]->(:C) RETURN a`
creates 2 **distinct** paths joined at node **a**. So, 3 **distinct** nodes
and 2 **distinct** edges.
```
psql-11.5-5432-pgsql=# SELECT * FROM cypher('test', $$ MATCH (u)-[e]->(v)
RETURN e $$) AS (e agtype);
e
----------------------------------------------------------------------------------------------------------------------------
{"id": 1125899906842658, "label": "incs", "end_id": 1407374883553314,
"start_id": 844424930132002, "properties": {}}::edge
{"id": 1125899906842659, "label": "incs", "end_id": 1407374883553315,
"start_id": 844424930132002, "properties": {}}::edge
(2 rows)
```
`()<-[]-(a)-[]->()`
The following -
`MATCH (a:A) WHERE exists(a.foo) WITH a OPTIONAL MATCH (a)-[:incs]->(c)
RETURN c`
matches those 2 **distinct** paths joined at **a** and returns **c** - each
paths' endpoint.
The following -
`MATCH (a:A) WHERE exists(a.foo) WITH a OPTIONAL MATCH
(a)-[:incs]->(c)-[d:incs]-() WITH a,c,COUNT(d) AS deps WHERE deps=1 RETURN
c,deps`
doesn't do what you may think it does. The result that you are expecting is
based on there being a **c** and a **d** value matched. However, there isn't.
```
psql-11.5-5432-pgsql=# SELECT * FROM cypher('test', $$ MATCH
(a)-[:incs]->(c)-[d:incs]-() RETURN c,d $$) AS (c agtype, d agtype);
c | d
---+---
(0 rows)
psql-11.5-5432-pgsql=#
```
There isn't a path from **a** to **c** and then back to **a**, without
reusing an edge. That's why it returns nothing.
Hopefully this is helpful.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]