Skip to content

Commit

Permalink
internal node IDs no longer automatically mapping to themselves as te…
Browse files Browse the repository at this point in the history
…mp IDs
  • Loading branch information
Paula Gearon committed Mar 19, 2021
1 parent 701daee commit 3bb499b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
(defproject org.clojars.quoll/zuko "0.4.6"
(defproject org.clojars.quoll/zuko "0.4.7"
:description "Threatgrid library for common graph database functionality"
:url "https://github.com/threatgrid/zuko"
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
:url "https://www.eclipse.org/legal/epl-2.0/"}
:dependencies [[org.clojure/clojure "1.10.2"]
:dependencies [[org.clojure/clojure "1.10.3"]
[org.clojars.quoll/naga-store "0.5.2"]
[prismatic/schema "1.1.12"]
[cheshire "5.10.0"]]
Expand Down
3 changes: 2 additions & 1 deletion src/zuko/entity/writer.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@
(defn new-node
[id]
(let [next-id (node/new-node *current-graph*)]
(vswap! *id-map* assoc (or id next-id) next-id)
(when id
(vswap! *id-map* assoc (or id next-id) next-id))
next-id))

(s/defn get-ref
Expand Down
8 changes: 4 additions & 4 deletions test/zuko/test_entity.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@
(with-fresh-gen
(let [data {:id "1234" :prop "value" :attribute 2}
[triples1 map1] (ident-map->graph data)
node1 (ffirst map1)
node1 (ffirst triples1)
data2 {:db/id node1 :prop "value" :attribute 2}
[triples2 map2] (ident-map->graph data2)
data3 {:db/id -1 :prop "value" :attribute 2}
Expand All @@ -270,12 +270,12 @@
node4 (get map7 -1)
node5 (get map7 -2)
node6 (->> triples7 (filter #(= :elts (second %))) first last)
node7 (-> map7 (dissoc -1) (dissoc -2) ffirst)
node7 (->> triples7 (filter #(and (= :name (second %)) (= "one" (nth % 2)))) ffirst)
node8 (->> triples7 (filter #(= :tg/rest (second %))) first last)
data8 {:db/id -1 :prop #{"value1" "value2"} :attribute 2}
[triples8 map8] (ident-map->graph data8)
node9 (get map8 -1)]
(is (= {node1 node1} map1))
(is (empty? map1))
(is (= #{[node1 :db/ident node1]
[node1 :tg/entity true]
[node1 :id "1234"]
Expand Down Expand Up @@ -313,7 +313,7 @@
[:tg/node-101 :attribute 2]
[:tg/node-101 :sub :tg/node-101]}
triples6))
(is (= {-1 node4 -2 node5 node7 node7} map7))
(is (= {-1 node4 -2 node5} map7))
(is (= #{[node4 :db/ident node4]
[node4 :tg/entity true]
[node4 :prop "value"]
Expand Down

0 comments on commit 3bb499b

Please sign in to comment.