-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
merge-configs doesn't allow explicit set of nil value #29
Comments
Now I see that it's somewhat a duplicate of this issue on weavejester/meta-merge |
I just realized that that (duct.core/merge-configs
{:duct.database.sql/hikaricp {:logger (duct.core.merge/replace nil)
:something-else :yay}}
{:duct.database.sql/hikaricp
^:demote {:jdbc-url "123"
:logger "999"}})
=> #:duct.database.sql{:hikaricp {:jdbc-url "123", :logger nil, :something-else :yay}} But I think that if this is expected then maybe the tests should include it to avoid confusion in expectations? |
Sure; I don't mind another test. As for why this is the behaviour in the first place, meta-merge is mimicing the behaviour of Leiningen's profile merging. |
Hmm... An update to what I said about the workaround using |
Can you give me a sample code that demonstrates the behaviour you're seeing? Duct modules should prefer your configuration over the defaults they add. |
(duct/prep-config
{:duct.profile/base
{:duct.database.sql/hikaricp {:logger (duct.core.merge/replace nil)}}
:duct.module/sql {:database-url "123"}}
profiles)
=>
{:duct.database.sql/hikaricp {:jdbc-url "123", :logger #integrant.core.Ref{:key :duct/logger}},
:duct.migrator/ragtime {:database #integrant.core.Ref{:key :duct.database/sql},
:strategy :raise-error,
:logger #integrant.core.Ref{:key :duct/logger},
:migrations []}} |
merge-configs
function, deeper down, uses apick-prioritized
function that, among other scenarios, picks anon-nil
value over anil
value. I suppose this is to deal with k-v pairs missing in one of the maps.But there are scenarios when one might want to explicitly set value of something to
nil
(like for:logger
for instance). And sadly this is not possible:Probably at one point Duct should be using a
contains?
function instead ofnil?
orsome?
at some point. I'm looking at these two lines.Would you consider that a bug? merge-configs fn tests don't include it so I'm not sure 🤔
The text was updated successfully, but these errors were encountered: