Permalink
Browse files

fix for corrupted rel indexes if retracting duplicate tuples

contains unit test

fix by David Liebke
  • Loading branch information...
jeffdik authored and David Nolen committed Sep 20, 2012
1 parent 3119b8a commit 715aebfbfc95f4332d98539583fd664b92e4810f
Showing with 18 additions and 1 deletion.
  1. +2 −1 src/main/clojure/clojure/core/logic.clj
  2. +16 −0 src/test/clojure/clojure/core/logic/tests.clj
@@ -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))))
@@ -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

0 comments on commit 715aebf

Please sign in to comment.