-
Notifications
You must be signed in to change notification settings - Fork 322
Cannot load JSON for certain field types using MariaDB #667
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
A solution I tried locally and worked was to add a line to this file like this: def loaders({:array, _}, type), do: [&json_decode/1, type] but I'm not surte if this unsupported feature was on purpose, so I prefer to wait for your thoughts before opening a PR - I can do it myself, just wanted to be sure this is a bug and not a feature |
Generally speaking, we expect adapters to already return the data in the correct format. So if your type is So if you can provide a way to make this feature opt-in, then we would gladly review it, but otherwise the underlying truth is that this type is simply not supported in their database of choice (and I can tell for certain that JSON operations such as |
Thanks for so quick response! I agree that the adapter should actually return the information in the expected. However I also see that on the file I linked there are already conversions for maps stored as JSON strings (maybe required for other scenarios as well?). I don't know if storing an I also agree that the developer experience using the wrong column type may be worse, so I completely understand your point. As for making the feature opt-in, I do not know how to manage that: Thanks for your time 🤗 Edit: I see that Oban does not support MariaDB because of the lack of proper JSON support, so maybe it is better to keep it as it is instead of trying to patch the lack of support by that DB engine. |
You are right. Since we already handle :map and this would be specific to MyXQL, a PR adding the change you requested would be welcome! |
Uh oh!
There was an error while loading. Please reload this page.
Elixir version
v1.17.3
Database and Version
MariaDB v11.5.2
Ecto Versions
ecto 3.11.2, ecto_sql 3.11.2
Database Adapter and Versions (postgrex, myxql, etc)
myxql 0.6.4
Current behavior
In the error_tracker we use a field of type
{:array, :string}
for the list opdf breadcrumbs of an occurrence (source).As we support all three major SQL databases (PostgreSQL, SQLite and MySQL/MariaDB), we need to implement the schema for all of them, so in the case of MySQL/MariaDB we implemented that field as a
:json
column (at the end, a list of strings is a valid JSON).It work as expecrted for MySQL, which implements the JSON column type. However, for MariaDB it does nopt work because it implements JSON columns as
longtext
columns, and on runtime it breaks with:The original issue can be found here
Expected behavior
I would expect it to load the content using a JSON parser, the same way it does for a
:map
field.The text was updated successfully, but these errors were encountered: