Answer the question
In order to leave comments, you need to log in
Doctrine + Postgres - how to build a QueryBuilder with JSON search?
There is a working SQL query:
SELECT * FROM "user" WHERE "roles"::text = '["ROLE_COURIER"]';
$role = '["ROLE_COURIER"]';
return $this->createQueryBuilder('user')
->where('user.roles = :role')
->setParameter('role', $role)
->getQuery()
->getResult()
;
SQLSTATE[42883]: Undefined function: 7 ERROR: operator does not exist: json = unknown
$role = '["ROLE_COURIER"]';
return $this->createQueryBuilder('user')
->where('"roles"::text = :role')
->setParameter('role', $role)
->getQuery()
->getResult()
;
[Syntax Error] line 0, col 44: Error: Expected Literal, got '"'
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question