elixir-toniq / vapor

Runtime configuration system for Elixir
MIT License
596 stars 37 forks source link

Config value datatypes assumed to always be strings or functions #42

Closed svan-jansson closed 4 years ago

svan-jansson commented 5 years ago

Hi, I've noticed a strange behavior when getting config values that are not strings. Take this example:

Here I'm setting a boolean value:

{:ok, true} = MyApp.Config.set("my_boolean_value",  true)

I then try to access it using the as: :bool parameter, but this happens:

{:error, Vapor.ConversionError} = MyApp.Config.get("my_boolean_value", as: :bool)

It will only work if i use the as: :string parameter, like this:

{:ok, true} = MyApp.Config.get("my_boolean_value", as: :string)

With the as: :string parameter I expected the returned value to always be a string, but the implementation is just a passthrough for the fetched value.

A suggestion solution is to add get/1 and get!/1, without the type argument, that returns the value exactly as it is stored.

keathley commented 5 years ago

Thanks for the report :). I think we’re going to rethink the way we specify types. The change is described in #43

keathley commented 4 years ago

Will be solved in #51