I have to do a query similar to this:
SomeModel::whereRaw("JSON_CONTAINS(column, '', '$.a')")->get();
column contains JSON *{"a":null}*;
With mysql version 5.7 everything works fine, i get empty collection but on a database on digitalocean which is mysql v8.0.17 i get this error:
Illuminate/Database/QueryException with message 'SQLSTATE[22032]: <>: 3141 Invalid JSON text in argument 1 to function json_contains: "The document is empty." at position 0. (SQL: select * from 'table' where JSON_CONTAINS(column, '', '$.a'))'
I'm stuck on this for days, please help! :)
The problem is empty string that you are passing as argument.
Try:
SomeModel::whereRaw("JSON_CONTAINS(column, null, '$.a')")->get();