我模型的一个属性是JSON类型.如果我使用希腊字符('μ'等)在JSON中,它们在MariaDB中被自动编码为unicode字符(例如,'μ'被键入为'\03bc').当我使用Eloquent进行读取时,数据会自动转换为有效字符.然而,如果我想通过'whereJsonContainsKey'在JSON中搜索包含字符'μ'的键,它找不到任何记录.对于常规字符,数据是正常搜索的.如何使用非标准字符搜索行?
我正在以这种方式创建数据:
$unit = Unit::factory()->create();
$unit->name = 'Some name';
$unit->unit = 'Ω';
$unit->prefixes = ['μ' => 0.000001, 'k' => 1000, 'M' => 1000000];
$unit->save();
then when I wand to fetch:
$u = Unit::whereJsonContainsKey('prefixes->μ')->first();
$u = null, but when
$u = Unit::whereJsonContainsKey('prefixes->k')->first();
the data is fetched correctly.