Skip to content

better match the behavior of assoc-in #33

@bn-darindouglass-zz

Description

@bn-darindouglass-zz

Currently cprop assumes that all parts of a key path are keywords. Because of this assumption, only nested maps may be overridden by ENV vars, System properties, et al.

However, cprop uses assoc-in to make these updates which can support indices if the current root level is a non-map:

user=> (def servers {:redis [{:url "hi"}]
  #_=>               :es [{:url "world"}
  #_=>                    {:url "!"}]})
#'user/servers
user=> (assoc-in servers [:redis 0 :url] "hello")
{:redis [{:url "hello"}], :es [{:url "world"} {:url "!"}]}

I propose one of two options:

  1. If a part of a path matches #"^\d+$" then it should be treated as a long instead of a keyword to better align with assoc-in's behavior.
  2. Provide a way to inject a parsing function into the k->path function so users can parse paths in ways they would expect.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions