From d3f78c3d4b95ed402280d93cee0be6f7be39f85e Mon Sep 17 00:00:00 2001 From: Tommi Reiman Date: Sat, 18 Mar 2023 19:33:29 +0200 Subject: [PATCH 1/3] format --- test/malli/util_test.cljc | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/test/malli/util_test.cljc b/test/malli/util_test.cljc index c8fa34207..2193aefa4 100644 --- a/test/malli/util_test.cljc +++ b/test/malli/util_test.cljc @@ -1,6 +1,6 @@ (ns malli.util-test (:require [clojure.test :refer [are deftest is testing]] - #?(:bb [cheshire.core :as json] + #?(:bb [cheshire.core :as json] :clj [jsonista.core :as json]) [malli.core :as m] [malli.impl.util :as miu] @@ -8,11 +8,11 @@ [malli.util :as mu])) #?(:clj (defn from-json [s] - #?(:bb (json/parse-string s) + #?(:bb (json/parse-string s) :clj (json/read-value s)))) #?(:clj (defn to-json [x] - #?(:bb (json/generate-string x) + #?(:bb (json/generate-string x) :clj (json/write-value-as-string x)))) (defn form= [& ?schemas] @@ -535,13 +535,13 @@ :c "a string"})))))) (deftest transform-entries-test - (let [registry (mr/composite-registry {:a/x int?} (m/default-schemas)) - options {:registry registry} + (let [registry (mr/composite-registry {:a/x int?} (m/default-schemas)) + options {:registry registry} key->key-transform #(map (fn [[k m _]] [k m k]) %) - schema [:map [:a/x {:m true} int?]] + schema [:map [:a/x {:m true} int?]] schema-with-options (m/schema schema options) - result-schema (m/schema [:map [:a/x {:m true} :a/x]] options)] + result-schema (m/schema [:map [:a/x {:m true} :a/x]] options)] (testing "manual options are preserved in output type from the transform" (is (mu/equals @@ -1013,27 +1013,27 @@ ff (conj f -f) tt (conj t -t)] (testing "every pred behaves like and: one false => result is false" - (is (true? ((miu/-every-pred [-t]) nil))) + (is (true? ((miu/-every-pred [-t]) nil))) (is (false? ((miu/-every-pred [-f]) nil))) - (is (true? ((miu/-every-pred t) nil))) + (is (true? ((miu/-every-pred t) nil))) (is (false? ((miu/-every-pred f) nil))) (is (false? ((miu/-every-pred t+f) nil))) (is (false? ((miu/-every-pred f+t) nil))) (is (false? ((miu/-every-pred tf) nil))) (is (false? ((miu/-every-pred ft) nil))) (is (false? ((miu/-every-pred ff) nil))) - (is (true? ((miu/-every-pred tt) nil)))) + (is (true? ((miu/-every-pred tt) nil)))) (testing "some pred behaves like or: one true => result is true" - (is (true? ((miu/-some-pred [-t]) nil))) + (is (true? ((miu/-some-pred [-t]) nil))) (is (false? ((miu/-some-pred [-f]) nil))) - (is (true? ((miu/-some-pred t) nil))) + (is (true? ((miu/-some-pred t) nil))) (is (false? ((miu/-some-pred f) nil))) - (is (true? ((miu/-some-pred t+f) nil))) - (is (true? ((miu/-some-pred f+t) nil))) - (is (true? ((miu/-some-pred tf) nil))) - (is (true? ((miu/-some-pred ft) nil))) + (is (true? ((miu/-some-pred t+f) nil))) + (is (true? ((miu/-some-pred f+t) nil))) + (is (true? ((miu/-some-pred tf) nil))) + (is (true? ((miu/-some-pred ft) nil))) (is (false? ((miu/-some-pred ff) nil))) - (is (true? ((miu/-some-pred tt) nil))))))) + (is (true? ((miu/-some-pred tt) nil))))))) (deftest explain-data-test (let [schema (m/schema [:map [:a [:vector [:maybe :string]]]]) From a6c51c0529d49437045bae4579cee3e789d87cd8 Mon Sep 17 00:00:00 2001 From: Tommi Reiman Date: Sat, 18 Mar 2023 19:34:59 +0200 Subject: [PATCH 2/3] fix #874 --- src/malli/core.cljc | 3 +-- test/malli/util_test.cljc | 10 ++++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/malli/core.cljc b/src/malli/core.cljc index 2636593b6..bb0682433 100644 --- a/src/malli/core.cljc +++ b/src/malli/core.cljc @@ -385,8 +385,7 @@ ;; update (-simple-entry-parser keyset (assoc children i c) (assoc forms i f)) ;; assoc - (let [size (inc (count keyset))] - (-simple-entry-parser (assoc keyset k size) (conj children c) (conj forms f)))))))) + (-simple-entry-parser (assoc keyset k {:order (count keyset)}) (conj children c) (conj forms f))))))) (defn -set-entries ([schema ?key value] diff --git a/test/malli/util_test.cljc b/test/malli/util_test.cljc index 2193aefa4..725e62f95 100644 --- a/test/malli/util_test.cljc +++ b/test/malli/util_test.cljc @@ -1074,3 +1074,13 @@ "schema" ["map" ["a" ["vector" ["maybe" "string"]]]] "value" {"a" [true]}} (from-json (to-json (mu/explain-data schema input-2))))))))) + +(deftest test-874 + (is (form= [:map {:closed true} + [:foo [:map {:closed true} + [:bar :int] + [:baz :int]]]] + (-> [:map] + (mu/assoc-in [:foo :bar] :int) + (mu/assoc-in [:foo :baz] :int) + (mu/closed-schema))))) From eb30b2d8bb8e22acd297b4239b2a311efcd84ef4 Mon Sep 17 00:00:00 2001 From: Tommi Reiman Date: Sat, 18 Mar 2023 19:36:41 +0200 Subject: [PATCH 3/3] CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f6e7c6da6..bfd6a90b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ Malli is in well matured [alpha](README.md#alpha). * `m/explicit-keys` to get a vector of explicit keys from entry schemas (no `::m/default` * `mt/strip-extra-keys-transformer` works with `:map-of` schemas * Simplify content-dependent schema creation with `m/-simple-schema` and `m/-collection-schema` via new 3-arity `:compile` function of type `children properties options -> props`. Old 2-arity top-level callback function is `m/deprecated!` and support for it will be removed in future versions. [#866](https://github.com/metosin/malli/pull/866) +* FIX Repeated calls to `malli.util/assoc-`in referencing non-existing maps fail [#874](https://github.com/metosin/malli/issues/874) ## 0.10.2 (2023-03-05)