diff --git a/src/datascript/db.cljc b/src/datascript/db.cljc index ed4c1193..c6ae2238 100644 --- a/src/datascript/db.cljc +++ b/src/datascript/db.cljc @@ -338,8 +338,8 @@ #?@(:clj [(instance? Number x) (clojure.lang.Numbers/compare x y)]) #?@(:clj [(instance? Comparable x) (.compareTo ^Comparable x y)] :cljs [(satisfies? IComparable x) (-compare x y)]) - #?@(:cljs [(and (or (string? x) (array? x) (true? x) (false? x)) - (identical? (type x) (type y))) (garray/defaultCompare x y)]) + #?@(:cljs [(not (identical? (type x) (type y))) (garray/defaultCompare (type x) (type y))]) + #?@(:cljs [(or (string? x) (array? x) (true? x) (false? x)) (garray/defaultCompare x y)]) :else (- (hash x) (hash y)))) (defn value-cmp [x y] diff --git a/test/datascript/test/transact.cljc b/test/datascript/test/transact.cljc index b8908729..e116f5ec 100644 --- a/test/datascript/test/transact.cljc +++ b/test/datascript/test/transact.cljc @@ -439,4 +439,30 @@ (vec (d/datoms db' :aevt :index 1 {:map 3})))) (is (= [(db/datom 1 :index {:map 3})] (vec (d/datoms db' :avet :index {:map 3} 1 ))))) -)) \ No newline at end of file +)) + +(deftest test-transitive-type-compare-386 + #?(:cljs + (let [txs [[{:block/uid "2LB4tlJGy"}] + [{:block/uid "2ON453J0Z"}] + [{:block/uid "2KqLLNbPg"}] + [{:block/uid "2L0dcD7yy"}] + [{:block/uid "2KqFNrhTZ"}] + [{:block/uid "2KdQmItUD"}] + [{:block/uid "2O8BcBfIL"}] + [{:block/uid "2L4ZbI7nK"}] + [{:block/uid "2KotiW36Z"}] + [{:block/uid "2O4o-y5J8"}] + [{:block/uid "2KimvuGko"}] + [{:block/uid "dTR20ficj"}] + [{:block/uid "wRmp6bXAx"}] + [{:block/uid "rfL-iQOZm"}] + [{:block/uid "tya6s422-"}] + [{:block/uid 45619}]] + schema {:block/uid {:db/unique :db.unique/identity}} + conn (d/create-conn schema) + _ (doseq [tx txs] (d/transact! conn tx)) + db @conn] + (is (empty? (->> (seq db) + (map (fn [[_ a v]] [a v])) + (remove #(d/entity db %))))))))