Route data maps ignore meta-merge options in 0.7.0, breaking compatibility
svdm opened this issue · comments
In 0.6.0, nested map data is merged in a way that matches meta-merge, supporting ^:replace
:
user> (meta-merge {:roles {:foo false :bar true}} {:roles ^:replace {:foo true}})
{:roles {:foo true}}
user> (r/routes (r/router
["/context" {:roles {:foo false :bar true}}
["/leaf" {:roles ^:replace {:foo true}}]]))
[["/context/leaf" {:roles {:foo true}}]]
In 0.7.0, this is no longer the case, ^:replace
is not respected:
user> (r/routes (r/router
["/context" {:roles {:foo false :bar true}}
["/leaf" {:roles ^:replace {:foo true}}]]))
[["/context/leaf" {:roles {:foo true, :bar true}}]]
This is not documented in the changelog so I assume it's not intentional.
I have found a workaround of sorts by fully disabling :update-paths
functionality:
user> (r/routes (r/router
["/context" {:roles {:foo false :bar true}}
["/leaf" {:roles ^:replace {:foo true}}]]
{:update-paths nil}))
[["/context/leaf" {:roles {:foo true}}]]
As a result presumably losing out on the schema merging fixes. (edit: Actually seems to cause more fundamental errors with plumatic schemas, so it's not a practical workaround.)
The root cause of the issue is that update-paths
strips metadata from nested maps (strictly: rebuilds the maps from scratch without retaining metadata), preventing meta-merge from ever seeing it, so it's not surprising that meta-merge directives on maps have no effect.
You are right, this is a regression.
fixed and released in 0.7.1.