Skip to content
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

SET on MERGE not storing edge properties inside the database on creation #1907

Closed
tvaeyens opened this issue Jun 4, 2024 · 8 comments
Closed
Labels
bug Something isn't working override-stale To keep issues/PRs untouched from stale action

Comments

@tvaeyens
Copy link

tvaeyens commented Jun 4, 2024

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 tvaeyens added the bug Something isn't working label Jun 4, 2024
@jrgemignani
Copy link
Contributor

@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=#

Copy link

github-actions bot commented Aug 4, 2024

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.

@github-actions github-actions bot added the Stale Stale issues/PRs label Aug 4, 2024
@MuhammadTahaNaveed MuhammadTahaNaveed added override-stale To keep issues/PRs untouched from stale action and removed Stale Stale issues/PRs labels Aug 4, 2024
@jrgemignani
Copy link
Contributor

@tvaeyens Looking into this

@jrgemignani
Copy link
Contributor

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=#

@jrgemignani
Copy link
Contributor

@tvaeyens PR #2019 addresses this issue and is currently in review.

@tvaeyens
Copy link
Author

tvaeyens commented Aug 8, 2024

@jrgemignani Thank you!

@jrgemignani
Copy link
Contributor

@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.

@tvaeyens
Copy link
Author

tvaeyens commented Aug 9, 2024

@jrgemignani I tried it again with the latest version of the master branch, I can confirm that this issue has been resolved!

Thank you!

@tvaeyens tvaeyens closed this as completed Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working override-stale To keep issues/PRs untouched from stale action
Projects
None yet
Development

No branches or pull requests

3 participants