|
| 1 | +LOAD 'age'; |
| 2 | +SET search_path TO ag_catalog; |
| 3 | +SELECT create_graph('cypher_path'); |
| 4 | +NOTICE: graph "cypher_path" has been created |
| 5 | + create_graph |
| 6 | +-------------- |
| 7 | + |
| 8 | +(1 row) |
| 9 | + |
| 10 | +-- Create vertex |
| 11 | +SELECT * FROM cypher('cypher_path', $$ |
| 12 | + CREATE (:label_name_1 {i: 0}) |
| 13 | +$$) as (a agtype); |
| 14 | + a |
| 15 | +--- |
| 16 | +(0 rows) |
| 17 | + |
| 18 | +-- Create a path to test our create, set and delete on. |
| 19 | +SELECT * |
| 20 | +FROM cypher('cypher_path', $$ |
| 21 | + CREATE p = (andres {name:'Andres'})-[:WORKS_AT]->(neo)<-[:WORKS_AT]-(michael {name:'Michael'})-[:WORKS_WITH]->(jordan {name: 'Jordan'}) |
| 22 | + RETURN p |
| 23 | +$$) as (p agtype); |
| 24 | + p |
| 25 | +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| 26 | + [{"id": 281474976710657, "label": "", "properties": {"name": "Andres"}}::vertex, {"id": 1125899906842626, "label": "WORKS_AT", "end_id": 281474976710658, "start_id": 281474976710657, "properties": {}}::edge, {"id": 281474976710658, "label": "", "properties": {}}::vertex, {"id": 1125899906842625, "label": "WORKS_AT", "end_id": 281474976710658, "start_id": 281474976710659, "properties": {}}::edge, {"id": 281474976710659, "label": "", "properties": {"name": "Michael"}}::vertex, {"id": 1407374883553281, "label": "WORKS_WITH", "end_id": 281474976710660, "start_id": 281474976710659, "properties": {}}::edge, {"id": 281474976710660, "label": "", "properties": {"name": "Jordan"}}::vertex]::path |
| 27 | +(1 row) |
| 28 | + |
| 29 | +-- Now delete one of the relationships nodes and the output should be return unchanged. |
| 30 | +SELECT * |
| 31 | +FROM cypher('cypher_path', $$ |
| 32 | + MATCH p = ()-[]->()<-[]-()-[]->(j) |
| 33 | + DETACH DELETE j |
| 34 | + RETURN p |
| 35 | +$$) AS (a agtype); |
| 36 | + a |
| 37 | +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| 38 | + [{"id": 281474976710657, "label": "", "properties": {"name": "Andres"}}::vertex, {"id": 1125899906842626, "label": "WORKS_AT", "end_id": 281474976710658, "start_id": 281474976710657, "properties": {}}::edge, {"id": 281474976710658, "label": "", "properties": {}}::vertex, {"id": 1125899906842625, "label": "WORKS_AT", "end_id": 281474976710658, "start_id": 281474976710659, "properties": {}}::edge, {"id": 281474976710659, "label": "", "properties": {"name": "Michael"}}::vertex, {"id": 1407374883553281, "label": "WORKS_WITH", "end_id": 281474976710660, "start_id": 281474976710659, "properties": {}}::edge, {"id": 281474976710660, "label": "", "properties": {"name": "Jordan"}}::vertex]::path |
| 39 | +(1 row) |
| 40 | + |
| 41 | +-- Now delete one of the edges and the path should be updated but output is still unchanged |
| 42 | +SELECT * |
| 43 | +FROM cypher('cypher_path', $$ |
| 44 | + MATCH p = (andres {name: 'Andres'})-[r:WORKS_AT]->(neo)<-[g:WORKS_AT]-(michael {name: 'Michael'}) |
| 45 | + DELETE g |
| 46 | + RETURN p |
| 47 | +$$) as (a agtype); |
| 48 | + a |
| 49 | +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 50 | + [{"id": 281474976710657, "label": "", "properties": {"name": "Andres"}}::vertex, {"id": 1125899906842626, "label": "WORKS_AT", "end_id": 281474976710658, "start_id": 281474976710657, "properties": {}}::edge, {"id": 281474976710658, "label": "", "properties": {}}::vertex, {"id": 1125899906842625, "label": "WORKS_AT", "end_id": 281474976710658, "start_id": 281474976710659, "properties": {}}::edge, {"id": 281474976710659, "label": "", "properties": {"name": "Michael"}}::vertex]::path |
| 51 | +(1 row) |
| 52 | + |
| 53 | +-- Create a path to test our create, set and delete on. |
| 54 | +SELECT * |
| 55 | +FROM cypher('cypher_path', $$ |
| 56 | + CREATE p = (andres {name:'Andres'})-[:CHILLS_AT]->(neo)<-[:CHILLS_SOME_MORE]-(michael {name:'Michael'}) |
| 57 | + RETURN p |
| 58 | +$$) as (p agtype); |
| 59 | + p |
| 60 | +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 61 | + [{"id": 281474976710661, "label": "", "properties": {"name": "Andres"}}::vertex, {"id": 1688849860263937, "label": "CHILLS_AT", "end_id": 281474976710662, "start_id": 281474976710661, "properties": {}}::edge, {"id": 281474976710662, "label": "", "properties": {}}::vertex, {"id": 1970324836974593, "label": "CHILLS_SOME_MORE", "end_id": 281474976710662, "start_id": 281474976710663, "properties": {}}::edge, {"id": 281474976710663, "label": "", "properties": {"name": "Michael"}}::vertex]::path |
| 62 | +(1 row) |
| 63 | + |
| 64 | +-- Attempt to delete anything other than vertex or edge. This should fail |
| 65 | +SELECT * |
| 66 | +FROM cypher('cypher_path', $$ |
| 67 | + MATCH p = (andres {name: 'Andres'})-[]->() |
| 68 | + DELETE p |
| 69 | + RETURN p |
| 70 | +$$) as (a agtype); |
| 71 | +ERROR: DELETE clause can only delete vertices and edges |
| 72 | +-- Cleanup |
| 73 | +SELECT drop_graph('cypher_path', true); |
| 74 | +NOTICE: drop cascades to 7 other objects |
| 75 | +DETAIL: drop cascades to table cypher_path._ag_label_vertex |
| 76 | +drop cascades to table cypher_path._ag_label_edge |
| 77 | +drop cascades to table cypher_path.label_name_1 |
| 78 | +drop cascades to table cypher_path."WORKS_AT" |
| 79 | +drop cascades to table cypher_path."WORKS_WITH" |
| 80 | +drop cascades to table cypher_path."CHILLS_AT" |
| 81 | +drop cascades to table cypher_path."CHILLS_SOME_MORE" |
| 82 | +NOTICE: graph "cypher_path" has been dropped |
| 83 | + drop_graph |
| 84 | +------------ |
| 85 | + |
| 86 | +(1 row) |
| 87 | + |
0 commit comments