Skip to content

Commit

Permalink
fix for corrupted rel indexes if retracting duplicate tuples
Browse files Browse the repository at this point in the history
contains unit test

fix by David Liebke
  • Loading branch information
jeffdik authored and David Nolen committed Oct 30, 2012
1 parent 3119b8a commit 715aebf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main/clojure/clojure/core/logic.clj
Expand Up @@ -2472,7 +2472,8 @@
(if (contains? m k)
(if-let [nv (empty-is-nil (f (get m k) v))]
(assoc m k nv)
(dissoc m k))))
(dissoc m k))
m))
merge-map (fn [m1 m2] (reduce merge-entry (or m1 {}) (seq m2)))]
(reduce merge-map maps))))

Expand Down
16 changes: 16 additions & 0 deletions src/test/clojure/clojure/core/logic/tests.clj
Expand Up @@ -1004,6 +1004,22 @@
(== a 2)))
'(1))))

(defrel rel2 ^:index e ^:index a ^:index v)
(facts rel2 [[:e1 :a1 :v1]
[:e1 :a2 :v2]])
(retractions rel2 [[:e1 :a1 :v1]
[:e1 :a1 :v1]
[:e1 :a2 :v2]])

(deftest rel2-dup-retractions
(is (= (run* [out]
(fresh [e a v]
(rel2 e :a1 :v1)
(rel2 e a v)
(== [e a v] out))))
'()))


;; -----------------------------------------------------------------------------
;; nil in collection

Expand Down

0 comments on commit 715aebf

Please sign in to comment.