Closed opqdonut closed 1 year ago
I tried to set ::walk-schema-refs
for m/closed-schema
(in #883), but it had some really funky consequences:
user> (def closed (mu/closed-schema [:schema {:registry {"Foo" [:map [:a :int]]}} "Foo"]))
#'user/closed
user> (m/form closed)
[:schema {:registry {"Foo" [:map [:a :int]]}} "Foo"]
user> (-> closed m/deref m/deref m/form)
[:map {:closed true} [:a :int]]
Even though the schema prints out as "Foo"
, it's not equal to the "Foo"
in the registry any more.
The result of
mu/closed-schema
needs one morem/deref
to get to the concrete schema. The same happens with a trivialm/schema-walker
use.Demonstration:
The root cause is the
-walk
implementation for-schema-schema
:This combined with
m/schema-walker
causes(m/-set-children schema [id])
, which overrides the child from:int
to"Foo"
. Luckily this doesn't cause a loop in later schema walking, just the need for one more deref.