Skip to content

Commit

Permalink
fix to assign json_library via Application env
Browse files Browse the repository at this point in the history
  • Loading branch information
hashijun committed Oct 22, 2017
1 parent cb8a783 commit f5703b2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,13 @@ After you are done, run `mix deps.get` in your shell to fetch and compile Mariae

Important configuration, which depends on used charset for support unicode chars, see `:binary_as`
in `Mariaex.start_link/1`

### JSON library

As default, [Poison](https://github.com/devinus/poison) is used for JSON library in mariaex to support JSON column.

If you want to use another library, please set `config.exs` like below.

```elixir
config :mariaex, json_library: SomeLibrary
```
1 change: 0 additions & 1 deletion lib/mariaex.ex
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ defmodule Mariaex do
in `GenServer.start_link/3`).
* `:datetime` - How datetimes should be returned. `:structs` for Elixir v1.3
calendar types or `:tuples` for the backwards compatible tuples
* `:json_library` - JSON Library to parse json column. (default: `Poison`)
## Function signatures
Expand Down
2 changes: 1 addition & 1 deletion lib/mariaex/protocol.ex
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ defmodule Mariaex.Protocol do
connect_opts = [host, opts[:port], opts[:socket_options], opts[:timeout]]
binary_as = opts[:binary_as] || :field_type_var_string
datetime = opts[:datetime] || :structs
json_library = opts[:json_library] || Poison
json_library = Application.get_env(:mariaex, :json_library, Poison)

case apply(sock_mod, :connect, connect_opts) do
{:ok, sock} ->
Expand Down

0 comments on commit f5703b2

Please sign in to comment.