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
Not fetching records matched by JSON column #4193
Comments
Technically it is a correct query, I am sure it would work fine when executed directly against the database (if not, mysql is really super weird, but hey, that's always possible too). The stored value is stringified too... Note that the very same query works with other drivers. The driver tries to do some JSON processing, but it's a bit weakly implemented, there are inconsistencies, especially with the string value example. I found also this old and unresolved issue sidorares/node-mysql2#1072 I am in the middle of a larger refactor of how the JSON values are processed, trying to disable any JSON handling in the lowest level, but apparently, it's not that easy, hard to call this configurable (the |
Thanks for quick reply and great ORM! mysql is weird indeed. First query returns nothing when executed directly in DB. I managed to make it work and prevent escaping strings via:
No ideal, but it works. |
Every driver behaves a bit differently when it comes to handling JSON columns. While SQLite is not processing then anyhow, and MongoDB supports them natively, all the others have rather quirky and not very configurable JSON parsing and stringification implemented. It is crucial to have the JSON values properly parsed, as well as normalized in the entity snapshot, so we can correctly detect updates. This PR makes the JSON parsing fail-safe, returning the value directly if it is not a valid JSON string, and ensures the entity data are in the right shape. Closes #4193
Every driver behaves a bit differently when it comes to handling JSON columns. While SQLite is not processing then anyhow, and MongoDB supports them natively, all the others have rather quirky and not very configurable JSON parsing and stringification implemented. It is crucial to have the JSON values properly parsed, as well as normalized in the entity snapshot, so we can correctly detect updates. This PR makes the JSON parsing fail-safe, returning the value directly if it is not a valid JSON string, and ensures the entity data are in the right shape. Closes mikro-orm#4193
Describe the bug
ORM escapes value in where clause on JSON column. Test below runs this query:
which returns 0 rows. It works and returns record if value isn't "stringified":
To Reproduce
Versions
The text was updated successfully, but these errors were encountered: