-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Get() and IsSet() work correctly on nested values
Rewriting of find(), which now checks for in-depth values, and ignores shadowed ones. * When looking for "foo.bar": - before: if "foo" was defined in some map, "foo.*" was looked for only in this map - now: "foo.*" is looked for in all maps, the first one with a value is used (even if "foo" was defined elsewhere, in a higher-priority map). * Also, find() tests that the requested key is not shadowed somewhere on its path. e.g., {"foo.bar": 1} in the config map shadows "foo.bar.baz" in the defaults map * Lastly, if in the config map, config["foo"]["bar"] and config["foo.bar"] coexist, the latter value is used. (this should not be necessary for other maps, since by construction their keys should not contain dots) => Get() and IsSet() corrected and simplified, since all the logic about value retrieval has been put in find() + README.md modified accordingly: In Section “Accessing nested keys”, to reflect the corrected behavior of find(): - paths searched for at all levels, not only the one of the first sub-key; - paths may be shadowed by a shorter, higher priority, path. + tests modified accordingly
- Loading branch information
1 parent
f513f5f
commit ae72cd4
Showing
3 changed files
with
203 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.