From 0158d4c29a0378832a2b66106c0c20636e285ede Mon Sep 17 00:00:00 2001 From: Josha von Gizycki Date: Fri, 25 Jan 2019 15:30:26 +0100 Subject: [PATCH] fix links getting the same uuid in batch operations --- src/wanijo/instance/domain.clj | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/wanijo/instance/domain.clj b/src/wanijo/instance/domain.clj index d9aee88..3ec9aa6 100644 --- a/src/wanijo/instance/domain.clj +++ b/src/wanijo/instance/domain.clj @@ -130,17 +130,23 @@ "MATCH (i:instance {uuid:{from}}), (u:user {uuid:{by}}), (t:instance) - WHERE t.uuid IN {to} + WHERE t.uuid = {target} CREATE (l:link {uuid:{uuid}})-[:created_by]->(u) SET l.created_at = {created_at}, l.name = {name} CREATE (i)<-[:link_from]-(l)-[:link_to]->(t)") (defn create-link! [link] - (neo4j/exec-query! create-link - (assoc link - :uuid (neo4j/uuid) - :created_at (neo4j/now-str)))) + (let [tuples (map (fn [target-uuid] + [create-link + {:from (:from link) + :by (:by link) + :target target-uuid + :uuid (neo4j/uuid) + :created_at (neo4j/now-str) + :name (:name link)}]) + (:to link))] + (apply neo4j/exec-queries! tuples))) (neo4j/defquery outgoing-links "MATCH (i:instance {uuid:{uuid}}),