DoctrineJsonFunctions
DoctrineJsonFunctions copied to clipboard
JSONB_CONTAINS : invalid token
Sorry but I can't find a proper example of the function for postgres running in symfony 7 and latest doctrine 3
I have a column location
containing a JSONB
like this:
{title:"blah blah", coordinates:..., etc ...}
I execute this query
$qb = $this->createQueryBuilder('a');
$qb = $qb->select('a.id', 'a.location');
$qb = $qb->where("JSONB_CONTAINS(a.location, 'title') LIKE :loc0");
$qb = $qb->setParameter('loc0', ' % blah% ');
$query = $qb->getQuery();
$result = $query->getResult();
error
SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for type json
LINE 1: ...AS location_1 FROM post p0_ WHERE p0_.location @> 'title' LI...
^
DETAIL: Token "title" is invalid.
CONTEXT: JSON data, line 1: title
conf:
dql:
numeric_functions:
rand: DoctrineExtensions\Query\Mysql\Rand
string_functions:
JSONB_CONTAINS: Scienta\DoctrineJsonFunctions\Query\AST\Functions\Postgresql\JsonbContains