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-uuid "4711"
:properties [{:type "string"
:value "dings-prop"}]})
)
:value "dings-prop"}]}))
(neo4j/defquery delete
"MATCH (i:instance {uuid: $uuid}),
@ -155,8 +154,13 @@
(i)-[tw:tagged_with]->()
OPTIONAL MATCH
(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,
l, tw, i")
l, tw, i, ric,
rpc, rev_prop, rev")
(defn delete! [uuid]
(neo4j/exec-query! delete {:uuid uuid}))

@ -79,9 +79,7 @@
(if (form/valid? form-def req)
(let [form-data (form/form-data form-def req)
form-instance (forms-inst/form-data->instance form-data attrs)
instance (assoc form-instance :uuid uuid)
_ (clojure.pprint/pprint instance)]
(clojure.pprint/pprint (files/persist-files! instance))
instance (assoc form-instance :uuid uuid)]
(db/edit! instance (domain/to-revision instance))
(resp/redirect (path :instance-show instance)))
(route-show! uuid req))))
@ -155,7 +153,7 @@
; (clojure.pprint/pprint names)
; (clojure.pprint/pprint instances)
; (clojure.pprint/pprint source-uuid)
#_ (clojure.pprint/pprint
#_(clojure.pprint/pprint
(map (fn [[target-schema target-instances]]
{:link-name (get names target-schema)
:instances target-instances})

@ -161,7 +161,15 @@
(str
"MATCH (p:property)
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"
(inst-routes/route-delete! (:uuid instance))

Loading…
Cancel
Save