metosin / malli

High-performance data-driven data specification library for Clojure/Script.
Eclipse Public License 2.0
1.44k stars 204 forks source link

mu/assoc fails when used with mu/get and local registry #928

Open stevebuik opened 10 months ago

stevebuik commented 10 months ago

using release 0.11.0

(let [location-schemas (merge {:address :string}
                                (m/default-schemas))]
    ; this is ok i.e. local registry can be used
    (-> [:map
         [:title :string]]
        (mu/assoc :location :address {:registry location-schemas}))
    ; this fails. combination of mu/get and local registry
    (-> [:map
         [:job [:map
                [:title :string]]]]
        (mu/get :job)
        (mu/assoc :location :address {:registry location-schemas}))
    ; this is ok i.e. no local registry
    (-> [:map
         [:job [:map
                [:title :string]]]]
        (mu/get :job)
        (mu/assoc :location :string))
    )
stevebuik commented 10 months ago

using Cursive debugger shows that....

malli.core/-set-entries at line 393 has a schema with no -options it was called from malli.utils/assoc where the schema was added

somehow the options are being lost

entirely possible I am misunderstanding how to use mu/assoc

if there is a workaround before the fix it would help but grateful for any help.

stevebuik commented 10 months ago

I found a workaround by avoid mu/assoc so low priority for me now

maybe still useful to know about edge case bugs