diff --git a/CHANGELOG.md b/CHANGELOG.md index c8778a7..476434a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## Changelog ### [Unreleased] +- fixed upsert eav with value nil ### [0.1.7] - 2018-05-05 #### Changed diff --git a/src/clara_eav/dsl.clj b/src/clara_eav/dsl.clj index 4092a2e..8c01f1a 100644 --- a/src/clara_eav/dsl.clj +++ b/src/clara_eav/dsl.clj @@ -63,7 +63,7 @@ (symbol? %))) (s/def ::a #(or (keyword? %) (symbol? %))) -(s/def ::v some?) +(s/def ::v any?) (s/def ::sexp list?) (s/def ::bind symbol?) diff --git a/src/clara_eav/eav.cljc b/src/clara_eav/eav.cljc index b18917e..f1a4f1a 100644 --- a/src/clara_eav/eav.cljc +++ b/src/clara_eav/eav.cljc @@ -43,7 +43,7 @@ (int? %) (uuid? %))) (s/def ::a keyword?) -(s/def ::v some?) +(s/def ::v any?) (s/def ::record (s/and #(instance? EAV %) (s/keys :req-un [::e ::a ::v]))) (s/def ::record-seq (s/coll-of ::record)) diff --git a/test/clara_eav/rules_test.cljc b/test/clara_eav/rules_test.cljc index b580566..0594667 100644 --- a/test/clara_eav/rules_test.cljc +++ b/test/clara_eav/rules_test.cljc @@ -1,5 +1,6 @@ (ns clara-eav.rules-test (:require [clara-eav.test-helper :as test-helper] + [clara-eav.eav :as eav] #?@(:clj [[clara.rules :as rules] [clara-eav.rules :as eav.rules] [clojure.test :refer [deftest testing is are use-fixtures]]] @@ -200,3 +201,14 @@ [] (transients session5) store5s (:store session5) tempids5s (:tempids session5))]))) + +(deftest upsert-nil-value + (testing "Upsert of eav with value nil" + (let [t {:eav/eid 1 :todo/text nil} + session1 (upsert session {:eav/eid 1 :todo/text nil}) + session2 (upsert session (eav/->EAV 1 :todo/text nil)) + session3 (upsert session [1 :todo/text nil])] + (are [x] (= t x) + (todo session1 1) + (todo session2 1) + (todo session3 1))))) \ No newline at end of file