Closed Billtec closed 1 month ago
Do you have an example of how you’re trying to use it exactly?
For example, I would like to query sth. inside a JSON type data field and the SQL should be SELECT JSON_QUERY(data,'$.info') FROM user WHERE JSON_VALUE(data, '$.info.birthyear') = 1990;
.
Ideally it can be done by using $user->select("JSON_QUERY(data,'$.info')")->eq("JSON_VALUE(data, '$.info.birthyear')", 1990)->find();
. However, since active record with automatically add the table name before each field, the SQL will be formed like SELECT user.JSON_QUERY(data,'$.info') FROM user WHERE user.JSON_VALUE(data, '$.info.birthyear') = 1990;
. Apparently it is not a valid SQL.
I believe this PR solves your problem. https://github.com/flightphp/active-record/pull/16 Let me know if it doesn't!
It seems that the JSON_* functions (like JSON_ARRAY, JSON_SEARCH) used to support JSON fields in new version of MySQL anb MariaDB cannot be used in current version of active-record.
Is there any workaround?