Skip to content

Commit

Permalink
Support collations
Browse files Browse the repository at this point in the history
  • Loading branch information
danharrin committed Oct 27, 2023
1 parent 59d8abb commit c89f86b
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions packages/support/src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,21 @@ function generate_search_column_expression(string $column, ?bool $isSearchForced
default => false,
};

if (! $isSearchForcedCaseInsensitive) {
return $column;
if ($isSearchForcedCaseInsensitive) {
$column = "lower({$column})";
}

$collation = $databaseConnection->getConfig('search_collation');

if (filled($collation)) {
$column = "{$column} collate {$collation}";
}

if ($isSearchForcedCaseInsensitive || filled($collation)) {
return new Expression($column);
}

return new Expression("lower({$column})");
return $column;
}
}

Expand Down

0 comments on commit c89f86b

Please sign in to comment.