I have a json
column in my database with french characters. So when I use:
App\Job::where('name->fr', 'like', '%Fune%')->count();
It is not finding results for jobs that has an accent in the name like Funéraire
. I can accomplish what I want by adding a collate in the query using the whereRaw
:
App\Job::whereRaw('json_unquote(json_extract(`name`, \'$."fr"\')) LIKE \'%Fune%\' collate utf8mb4_general_ci')->count();
However, when I use bindings in my whereRaw
method:
App\Job::whereRaw('json_unquote(json_extract(`name`, \'$."fr"\')) LIKE ? collate utf8mb4_general_ci', ['%Fune%'])->count();
I am receiving a database error:
COLLATION 'utf8mb4_general_ci' is not valid for CHARACTER SET 'binary' (SQL: select count(*) from
jobs
where json_unquote(json_extract(name
, '$."fr"')) LIKE %Fune% collate utf8mb4_general_ci)
Just wondering why it's not working when I'm passing it with bindings.