-
Notifications
You must be signed in to change notification settings - Fork 48
Ecto expectations for map fields #41
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
Comments
I'm fairly certain this is due to differences between
My idea is that is the cause of the issue. This library is not letting the data returned from the query go through the full Ecto "pipeline" and allowing our loaders to be run. Specifically these lines at
The fix is either:
Either (1) or (2) I think is the preferred solution. I hope that makes sense. You may need to coordinate with the maintainer of that library for the fix. I'll keep this issue open for now, though I don't think there is anything on our end we can do. -- Edit: If (1) or (2) above end up being ill-advised, clunky, or not possible when consulting with the maintainer of |
I'm curious if this is also an issue with the MySQL adapter. I based a lot of the sqlite3 adapter off of it. |
@mathieuprog this is the same issue I posted in the polymorphic_embed repo mathieuprog/polymorphic_embed#39. When you get a chance do you mind reporting back how we should move forward with it? Thanks for the detailed response @kevinlang |
If it is a limitation (purposely) of |
Yep, I think (1) would not work. I'm not too familiar with ParamaterizedTypes, but reading through briefly I now understand that ultimately your library is its own "type", so we wouldn't have any loader to process it anyway. I agree that (2) seems the way to go, if we do not want to make changes to @warmwaffles I don't think it is an issue with the MySQL driver, based on this file: There I see that the driver is encoding the json column response directly into an Elixir map, so the ParamaterizedType would get that value to process on load. |
We probably need to make if function similarly. |
Closing as @mathieuprog has merged a fix. Cheers @warmwaffles @kevinlang. |
Uh oh!
There was an error while loading. Please reload this page.
Howdy,
I'm trying to use the polymorphic_embed library with the SQLite3 ecto adapter and I'm running into an error loading the map field. It works correctly with the ecto postgres adapter. It seems like ecto is expecting JSON fields to be deserialized from a string to a struct.
I've created a branch to reproduce to problem
https://github.com/fremantle-industries/tai/tree/sqlite3-polymorphic-embed-invalid-map-field
The embed field is defined in the
OrderTransition
schemahttps://github.com/fremantle-industries/tai/blob/sqlite3-polymorphic-embed-invalid-map-field/apps/tai/lib/tai/orders/order_transition.ex#L20
The text was updated successfully, but these errors were encountered: