elixir-toniq / vapor

Runtime configuration system for Elixir

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Config value datatypes assumed to always be strings or functions

svan-jansson opened this issue · comments

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.

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

Will be solved in #51