commanded / eventstore

Event store using PostgreSQL for persistence
MIT License
1.06k stars 146 forks source link

module Jason is not available when appending to jsonb event store #154

Closed mwillema closed 5 years ago

mwillema commented 5 years ago

When I want to append some events to the event store using the jsonb encoding, I got the following trace:

** (UndefinedFunctionError) function Jason.encode_to_iodata!/1 is undefined (module Jason is not available)
    Jason.encode_to_iodata!(%{"brand_uuid" => "MyBrand"})
    (postgrex) lib/postgrex/type_module.ex:713: Postgrex.DefaultTypes.encode_params/3
    (postgrex) lib/postgrex/query.ex:62: DBConnection.Query.Postgrex.Query.encode/3
    (db_connection) lib/db_connection.ex:1088: DBConnection.encode/5
    (db_connection) lib/db_connection.ex:1186: DBConnection.run_prepare_execute/5
    (db_connection) lib/db_connection.ex:504: DBConnection.parsed_prepare_execute/5
    (db_connection) lib/db_connection.ex:497: DBConnection.prepare_execute/4
    (postgrex) lib/postgrex.ex:182: Postgrex.query_prepare_execute/4
slashdotdash commented 5 years ago

You need to include the Jason library in mix.exs to use the jsonb data type:

defp deps do
  [{:jason, "~> 1.1"}]
end

That will enable the Postgrex types with JSON support.