age
age copied to clipboard
SET on MERGE not storing edge properties inside the database on creation
Describe the bug When using a MERGE for a relation between two nodes that is not present in the database, the properties are not stored inside the database.
How are you accessing AGE (Command line, driver, etc.)?
- Age viewer
- Python Driver
What data setup do we need to do?
SELECT * FROM ag_catalog.create_graph('test_graph');
SELECT * from cypher('test_graph', $$
CREATE (n:Testnode {name: 'Test Node A'})
RETURN n
$$) as (n agtype);
SELECT * from cypher('test_graph', $$
CREATE (n:Testnode {name: 'Test Node B'})
RETURN n
$$) as (n agtype);
What is the necessary configuration info needed? N/A
What is the command that caused the error?
SELECT * FROM cypher('test_graph', $$
MATCH (a)
WHERE a.name= 'Test Node A'
MATCH (b)
WHERE b.name= 'Test Node B'
MERGE (a)-[r:RELATED_TO]->(b)
SET r = {property1: 'something', property2: 'else'}
RETURN r
$$) AS (r agtype);
This gives the following output which is correct:
{"id":1125899906842625,"label":"RELATED_TO","end_id":844424930131970,"start_id":844424930131969,"properties":{"property1":"something","property2":"else"}}
When executing the next query:
SELECT * FROM cypher('test_graph', $$
MATCH (a)-[r]->(b)
return a, r, b
$$) AS (a agtype, r agtype, b agtype);
This following output is received:
{"id":844424930131969,"label":"Testnode","properties":{"name":"Test Node A"}} ,{"id":1125899906842625,"label":"RELATED_TO","end_id":844424930131970,"start_id":844424930131969,"properties":{}} ,{"id":844424930131970,"label":"Testnode","properties":{"name":"Test Node B"}}
As you can see, the edge properties are not here anymore. Is this expected behavior? Or does this type of queries need to be formed in another way?
When looking inside the postgres database tables, the properties are also not there
Expected behavior I thought the edge properties would still be present when executing the last query.
Environment (please complete the following information):
- Running from the apache/age:latest Docker image
Additional context N/A
@tvaeyens I was able to reproduce your error -
psql-16.2-5432-pgsql=# SELECT * FROM cypher('test_graph', $$
psql-16.2-5432-pgsql$# MATCH (a)-[r]->(b)
psql-16.2-5432-pgsql$# return a, r, b
psql-16.2-5432-pgsql$# $$) AS (a agtype, r agtype, b agtype);
a |
r |
b
---------------------------------------------------------------------------------------------+--------------------------------------
-------------------------------------------------------------------------------------------+----------------------------------------
-----------------------------------------------------
{"id": 844424930131969, "label": "Testnode", "properties": {"name": "Test Node A"}}::vertex | {"id": 1125899906842625, "label": "RE
LATED_TO", "end_id": 844424930131970, "start_id": 844424930131969, "properties": {}}::edge | {"id": 844424930131970, "label": "Testn
ode", "properties": {"name": "Test Node B"}}::vertex
(1 row)
psql-16.2-5432-pgsql=#
This issue is stale because it has been open 60 days with no activity. Remove "Abondoned" label or comment or this will be closed in 14 days.
@tvaeyens Looking into this
I could have sworn that we fixed this bug a while ago. Sigh,... here it is with just a simple merge command.
psql-16.2-5432-psql=# SELECT * FROM cypher('test_graph', $$
MERGE (a {name: 'Test Node A'})-[r:RELATED_TO]->(b {name: 'Test Node B'})
SET r = {property1: 'something'} RETURN r $$) AS (r agtype);
r
------------------------------------------------------------------------------------------------------------------------------------
---------------------
{"id": 1125899906842630, "label": "RELATED_TO", "end_id": 281474976710664, "start_id": 281474976710663, "properties": {"property1":
"something"}}::edge
(1 row)
psql-16.2-5432-psql=# SELECT * FROM cypher('test_graph', $$ MATCH (a)-[r]->(b) return r $$) AS (r agtype);
r
---------------------------------------------------------------------------------------------------------------------------------
{"id": 1125899906842630, "label": "RELATED_TO", "end_id": 281474976710664, "start_id": 281474976710663, "properties": {}}::edge
(1 row)
psql-16.2-5432-psql=#
@tvaeyens PR #2019 addresses this issue and is currently in review.
@jrgemignani Thank you!
@tvaeyens The fix is now in the master branch. I have submitted PRs to apply the fix to all of the lower branches. These are currently in review.
@jrgemignani I tried it again with the latest version of the master branch, I can confirm that this issue has been resolved!
Thank you!