laravel / ideas

Issues board used for Laravel internals discussions.
938 stars 28 forks source link

Add case insensitive searching to JSON Column #2609

Open karimov-javokhir opened 3 years ago

karimov-javokhir commented 3 years ago

I was searching a translatable JSON column on MySql using ->where('name->first', 'like', '%jeRRy%'). But this returned 0 results. In database, there is data and it's like this: { "first":"Jerry", "last":"Kim" } My table column name has insensitive collation!

My solution was to lower case my searching term and extract json attribute "first" like this: ->whereRaw('LOWER(first->"$.") like ?', mb_strtolower("%jeRRy%")) this was suggested in MySql Docs

This worked fine in my problem. but, I think it's a bit incorrect way considering chars like 'å' I think this solution was way better to use collation

This would be good to have the option to search JSON columns with original column collation!!!