I have my roles of my users with type json and I would like to get the list of users by roles.
/**
* @ORM\Column(type="json")
*/
private $roles = [];
$queryBuilder
->where("$rootAlias.roles LIKE :role")
->setParameter('role', '["ROLE_USER"]')
;
This is the error I get:
An exception occurred while executing a query: SQLSTATE[42883]: Undefined function: 7 ERROR: operator does not exist: json ~~ unknown\nLINE 1: ...ce s1_ ON u0_.service_id = s1_.id WHERE u0_.roles LIKE $1 OR...\n
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
It works great like this "roles"::TEXT LIKE :role
but I don't know how to convert "roles"::TEXT
in query builder?