Skip to content

Commit

Permalink
Merge pull request #15267 from dododedodonl/fix-case-search-json
Browse files Browse the repository at this point in the history
Fix forced lower case search for json field
  • Loading branch information
danharrin authored Jan 9, 2025
2 parents cf5c208 + 215e662 commit 0ad682f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/support/src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ function generate_search_column_expression(string $column, ?bool $isSearchForced
};

if ($isSearchForcedCaseInsensitive) {
if (in_array($driverName, ['mysql', 'mariadb'], true) && str($column)->contains('->') && ! str($column)->startsWith('json_extract(')) {
[$field, $path] = invade($databaseConnection->getQueryGrammar())->wrapJsonFieldAndPath($column); /** @phpstan-ignore-line */

$column = "json_extract({$field}{$path})";
}

$column = "lower({$column})";
}

Expand Down

0 comments on commit 0ad682f

Please sign in to comment.