You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, above error can be reproduced by following snippet:
importkuzufromuuidimportuuid4importtempfilewithtempfile.TemporaryDirectory() asdbpath:
conn=kuzu.Connection(kuzu.Database(dbpath))
conn.execute(
""" CREATE NODE TABLE T (id UUID, PRIMARY KEY(id)); CREATE NODE TABLE U (id UUID, name STRING, PRIMARY KEY(id)); CREATE REL TABLE has (FROM T TO U); """,
)
# Prerequirement: existing :Ttid=uuid4()
conn.execute("CREATE (t:T {id: $id}) RETURN t;", {"id": tid})
# Merge :U from memory (new here, but might already exist)uid=uuid4()
conn.execute(
""" MATCH (t:T {id: $tid}) // (1) MERGE (u:U {id: $uid}) // (2) SET u.name = $name // (3) MERGE (t)-[e:has]->(u) RETURN t,u,e; """,
{"tid": tid, "uid": uid, "name": "foo"},
)
Some background for clarification:
Goal was to construct a simple kind of object graph mapper (OGM) with MERGE: Given entities T,U with composite relation (:T)-[:has]->(:U), try to merge a new or existing U from memory.
(1) ensures :T exists
(2) merges an :U by its identifier (otherwise MERGE would try to create a new entity, if any property has changed)
(3) update all :U properties in database (assuming object memory has most recent version or creates new entity)
Kuzu 0.4.2
The text was updated successfully, but these errors were encountered:
Hi, above error can be reproduced by following snippet:
Some background for clarification:
Goal was to construct a simple kind of object graph mapper (OGM) with
MERGE
: Given entitiesT
,U
with composite relation(:T)-[:has]->(:U)
, try to merge a new or existingU
from memory.(1) ensures
:T
exists(2) merges an
:U
by its identifier (otherwiseMERGE
would try to create a new entity, if any property has changed)(3) update all
:U
properties in database (assuming object memory has most recent version or creates new entity)Kuzu 0.4.2
The text was updated successfully, but these errors were encountered: