Skip to content

Commit eadaa83

Browse files
committedFeb 4, 2023
Support PostgreSQL case insensitive queries with ILIKE (#24)
1 parent 8163bf2 commit eadaa83

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed
 

‎src/UniqueTranslationValidator.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,13 @@ protected function findTranslation($connection, $table, $column, $locale, $value
234234
$escaped = DB::getDriverName() === 'sqlite' ? '\\\\' : '\\\\\\\\';
235235
$value = str_replace('\\', $escaped, $value);
236236

237+
// Support PostgreSQL case insensitive queries with ILIKE
238+
$operator = DB::getDriverName() === 'pgsql' ? 'ILIKE' : 'LIKE';
239+
237240
return DB::connection($connection)->table($table)
238-
->where(function ($query) use ($column, $locale, $value) {
239-
$query->where($column, 'LIKE', "%\"{$locale}\": \"{$value}\"%")
240-
->orWhere($column, 'LIKE', "%\"{$locale}\":\"{$value}\"%");
241+
->where(function ($query) use ($column, $operator, $locale, $value) {
242+
$query->where($column, $operator, "%\"{$locale}\": \"{$value}\"%")
243+
->orWhere($column, $operator, "%\"{$locale}\":\"{$value}\"%");
241244
});
242245
}
243246

0 commit comments

Comments
 (0)
Please sign in to comment.