Error with UNACCENT
pesseyjulien opened this issue · comments
Julien Pessey commented
HI,
I'm getting an error using the unaccent function :
An exception has been thrown during the rendering of a template ("An exception occurred while executing a query: SQLSTATE[42883]: Undefined function: 7 ERROR: function unaccent(character varying) does not exist
LINE 1: ... status s3_ ON s2_.status_id = s3_.id WHERE LOWER(unaccent(c...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.").
My Config :
doctrine:
orm:
dql:
datetime_functions:
DATE: Oro\ORM\Query\AST\Functions\SimpleFunction
numeric_functions:
TIMESTAMPDIFF: Oro\ORM\Query\AST\Functions\Numeric\TimestampDiff
string_functions:
UNACCENT: MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\Unaccent
JSONB_EXISTS: MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\JsonbExists
ANY_OF: MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\Any
LEAST: MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\Least
GREATEST: MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\Greatest
STRING_TO_ARRAY: MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\StringToArray
JSON_GET_FIELD: MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\JsonGetField
JSON_GET_FIELD_AS_TEXT: MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\JsonGetFieldAsText
And my code :
$qb = $this->em->createQueryBuilder()
->select('entity')
->from($entityClass, 'entity')
->leftJoin('entity.company_client', 'company')
->leftJoin('entity.current_status', 'statusDetails')
->leftJoin('statusDetails.status', 'status')
->where('LOWER(UNACCENT(company.commercial_name)) LIKE :query')
->orWhere("entity.number LIKE :query")
->orWhere('LOWER(status.label) LIKE :query')
->setParameter('query', '%'.$searchQuery.'%');
Any idea what could be wrong ? The other functions seems to be working.
Thanks in advance for your help,
Julien
Julien Pessey commented
Weird thing, it's not working in dev but working in prod...
Julien Pessey commented
My bad, I needed to run : CREATE EXTENSION unaccent;