-
Notifications
You must be signed in to change notification settings - Fork 32
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
field updated_at waffle.Ecto.type in a embed schema #19
Comments
Hi, thank your for reporting this issue and providing an example.
|
Hello, did you have the time to check ? |
@mrdotb PR is welcome |
Hello. |
- fixes elixir-waffle#19 By default Ecto uses :self strategy which encodes the type without calling load/1 or dump/1 on custom type. So Waffle.Ecto.Type was encoded and decoded as a json, with native Ecto tools -> it was stored as an actual json in DB instead of using `filename_with_timestamp` string representation defined in Waffle.Ecto.Type BREAKING CHANGE: this commit will "break" loading existing embedded fieds from DB that used previous waffle versions. Now Waffle.Ecto.Type expects `value` to be a string, but old representation will feed it a map. Depending on your ecto adapter, you can fix it by: a) re-dumping all values to your db properly b) adding Waffle.Ecto.Type.load/2 for a json Map values and parsing "updated_at" map value to NaiveDateTime from a representation specific to your adapter
@mrdotb @Faymir I made a PR, but if you need to fix this asap - you can write your own version of Honestly, it's quite sad that things like this bug are not being fixed in the elixir community for years... I wonder why. Because nobody stores filenames inside embeds? Maybe nobody uses this in production? Or everyone's using another lib for file uploading? |
I guess not much people use it as embed. Glad you found the root cause. I tried a bit and I ended up not using |
Hello,
When I write some tests I found a weird behavior from
waffle_ecto
The
updated_at
type return from insert differ from select. (NaiveDateTime
toString
)I did an example with phoenix since it happen when the data is inserted in postgres.
Basically I got a embeds_many who use
Waffle.Ecto.Schema
In the test result the updated_at field in the embeds_many is a NaiveDateTime on insert and a String on select
Is this behavior expected ? (since it's stored in text format and not timestamp)
Thanks for your time.
The text was updated successfully, but these errors were encountered: