Added a custom function to make PostgresSQL searches case insensitive

This is required only for postgres as every other database is case invariant by default. But to achieve a portable way, we implement it via a custom DQL function.

This fixes issue #784
This commit is contained in:
Jan Böhmer 2024-12-02 00:17:54 +01:00
parent b1ba26e0b9
commit e223078af9
11 changed files with 94 additions and 22 deletions

View file

@ -50,7 +50,7 @@ final class LikeFilter extends AbstractFilter
}
$parameterName = $queryNameGenerator->generateParameterName($property); // Generate a unique parameter name to avoid collisions with other filters
$queryBuilder
->andWhere(sprintf('o.%s LIKE :%s', $property, $parameterName))
->andWhere(sprintf('ILIKE(o.%s, :%s) = TRUE', $property, $parameterName))
->setParameter($parameterName, $value);
}

View file

@ -61,10 +61,10 @@ final class TagFilter extends AbstractFilter
$expr = $queryBuilder->expr();
$tmp = $expr->orX(
$expr->like('o.'.$property, ':' . $tag_identifier_prefix . '_1'),
$expr->like('o.'.$property, ':' . $tag_identifier_prefix . '_2'),
$expr->like('o.'.$property, ':' . $tag_identifier_prefix . '_3'),
$expr->eq('o.'.$property, ':' . $tag_identifier_prefix . '_4'),
'ILIKE(o.'.$property.', :' . $tag_identifier_prefix . '_1) = TRUE',
'ILIKE(o.'.$property.', :' . $tag_identifier_prefix . '_2) = TRUE',
'ILIKE(o.'.$property.', :' . $tag_identifier_prefix . '_3) = TRUE',
'ILIKE(o.'.$property.', :' . $tag_identifier_prefix . '_4) = TRUE',
);
$queryBuilder->andWhere($tmp);