fix deletion of instances with revisions

master
Josha von Gizycki 2 years ago
parent 57412a5544
commit c7b3f4e69a

@ -141,8 +141,7 @@
{:instance-name "dings" {:instance-name "dings"
:instance-uuid "4711" :instance-uuid "4711"
:properties [{:type "string" :properties [{:type "string"
:value "dings-prop"}]}) :value "dings-prop"}]}))
)
(neo4j/defquery delete (neo4j/defquery delete
"MATCH (i:instance {uuid: $uuid}), "MATCH (i:instance {uuid: $uuid}),
@ -155,8 +154,13 @@
(i)-[tw:tagged_with]->() (i)-[tw:tagged_with]->()
OPTIONAL MATCH OPTIONAL MATCH
(i)-[l:link]-() (i)-[l:link]-()
OPTIONAL MATCH
(i)<-[ric:of]-(rev:revision)
OPTIONAL MATCH
(rev_prop:rev_property)-[rpc:of]->(rev)
DELETE pac, pc, cb, ic, p, DELETE pac, pc, cb, ic, p,
l, tw, i") l, tw, i, ric,
rpc, rev_prop, rev")
(defn delete! [uuid] (defn delete! [uuid]
(neo4j/exec-query! delete {:uuid uuid})) (neo4j/exec-query! delete {:uuid uuid}))

@ -79,9 +79,7 @@
(if (form/valid? form-def req) (if (form/valid? form-def req)
(let [form-data (form/form-data form-def req) (let [form-data (form/form-data form-def req)
form-instance (forms-inst/form-data->instance form-data attrs) form-instance (forms-inst/form-data->instance form-data attrs)
instance (assoc form-instance :uuid uuid) instance (assoc form-instance :uuid uuid)]
_ (clojure.pprint/pprint instance)]
(clojure.pprint/pprint (files/persist-files! instance))
(db/edit! instance (domain/to-revision instance)) (db/edit! instance (domain/to-revision instance))
(resp/redirect (path :instance-show instance))) (resp/redirect (path :instance-show instance)))
(route-show! uuid req)))) (route-show! uuid req))))

@ -161,7 +161,15 @@
(str (str
"MATCH (p:property) "MATCH (p:property)
WHERE p.uuid = '" prop-uuid "' WHERE p.uuid = '" prop-uuid "'
RETURN p.value")))))) RETURN p.value"))))
(is (= "new-value"
(single-result
(str
"MATCH (rp:rev_property)
-[:of]->(rev:revision)
-[:of]->(i:instance)
WHERE i.uuid = '" (:uuid instance) "'
RETURN rp.value"))))))
(testing "delete first instance" (testing "delete first instance"
(inst-routes/route-delete! (:uuid instance)) (inst-routes/route-delete! (:uuid instance))

Loading…
Cancel
Save