diangamichael commented on issue #1709:
URL: https://github.com/apache/age/issues/1709#issuecomment-2035541941

   The issue you're encountering is because of the way you're merging and 
setting properties in your Cypher query. When you use MERGE, it will only 
create a new node if it doesn't already exist with the specified properties. 
However, in your case, you're using SET after MERGE, which can overwrite 
existing properties on the node.
   
   To fix this issue and ensure that properties are correctly set for all 
nodes, you should use ON CREATE SET in addition to SET. This will only set 
properties if the node is newly created during the MERGE operation.
   
   Here's the corrected query:
   
   SELECT * FROM cypher('playground', $$
     UNWIND [{first: 'jon', last: 'snow'}, {first: 'ned', last: 'stark'}] AS map
     MERGE (v:PERSON {first: map.first})
     ON CREATE SET v=map
     SET v.last = map.last
     RETURN v
   $$) AS (v agtype);
   With this modification, each node will have its properties correctly set, 
even if they already exist in the database.


-- 
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: dev-unsubscr...@age.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to