-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Which serializer to use when using with both Commanded and jsonb? #185
Comments
The Instead, you can use this |
I was using the config :my_app, MyApp.EventStore,
column_data_type: "jsonb",
serializer: Commanded.Serialization.JsonSerializer,
types: EventStore.PostgresTypes It also works with So, how is it not supposed to work? |
The migration from Poison to Jason for JSON serialization might explain why it's working. I will need to investigate. Maybe we can now deprecate the |
I would say it actually works better with the When I use the jsonb serializer. events with maps that have nested string keys, breaks on deserialization as it recursively runs String.to_existing_atom(key) and the nested string keys may not be existing atoms (rightly so). |
@slashdotdash I am hitting the error that @ItsRaWithTheH mentioned:
How can I make this work? The nested string keys, is because the event contains a "raw" field which is passed through by the caller. However, I cannot get deserialize to work. It is also worth mentioning that this bug is only seen in tests when switching to a PG backend, it does not get reproduced when using the InMemory adapter. 😕 Here is an example, using defmodule Commands.MyCommand do
use Commanded.Command,
item_ref: :string,
raw: :map
end
defmodule Events.MyEvent do
use Commanded.Event,
from: Commands.MyCommand
end
# Commands.MyCommand.new(%{item_ref: 1, data: %{"foo" => "bar"}}) # OK
# Commands.MyCommand.new(%{item_ref: 1, data: %{"foo" => %{"baz" => "bar"}}}) # FAIL |
Coming in kind of late here! @datafoo you said:
I'm in the process of upgrading an app from commanded 0.19.1 to 1.1.1, and as part of this also upgrading from eventstore 0.17.0 to 1.1.0. The app was already using the I found that if I specified the So, I did end up using the
Hopefully this helps someone. |
A note was recently added in the Getting started guide:
The same guide also states:
So, what is the recommended configuration when using the event store with both Commanded and
jsonb
? Is the following correct?The text was updated successfully, but these errors were encountered: