Skip to content

Commit

Permalink
bug #6292 Fix search engine for PostgreSQL databases when querying nu…
Browse files Browse the repository at this point in the history
…mbers (javiereguiluz)

This PR was merged into the 4.x branch.

Discussion
----------

Fix search engine for PostgreSQL databases when querying numbers

Fixes #6290.

Commits
-------

063283d Fix search engine for PostgreSQL databases when querying numbers
  • Loading branch information
javiereguiluz committed May 2, 2024
2 parents ad5fae6 + 063283d commit 91b5b08
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Orm/EntityRepository.php
Expand Up @@ -122,7 +122,8 @@ private function addSearchClause(QueryBuilder $queryBuilder, SearchDto $searchDt
$queryBuilder->setParameter($parameterName, $dqlParameters['uuid_query'], 'ulid');
} elseif ($propertyConfig['is_text'] || $propertyConfig['is_integer']) {
$parameterName = sprintf('query_for_text_%d', $queryTermIndex);
$queryTermConditions->add(sprintf('LOWER(%s.%s) LIKE :%s', $entityName, $propertyConfig['property_name'], $parameterName));
// concatenating an empty string is needed to avoid issues on PostgreSQL databases (https://github.com/EasyCorp/EasyAdminBundle/issues/6290)
$queryTermConditions->add(sprintf('LOWER(CONCAT(%s.%s, \'\')) LIKE :%s', $entityName, $propertyConfig['property_name'], $parameterName));
$queryBuilder->setParameter($parameterName, $dqlParameters['text_query']);
} elseif ($propertyConfig['is_json'] && !$isPostgreSql) {
// neither LOWER() nor LIKE() are supported for JSON columns by all PostgreSQL installations
Expand Down

0 comments on commit 91b5b08

Please sign in to comment.