-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Description
The issue is, when using Raw DQL (or building the query) Doctrine does not have the context, and does not know what is an Ulid. When you call setParameter
without providing the $type
argument, Doctrine try to guess the type, and, sadly, the logic is very simplistic (see https://github.com/doctrine/orm/blob/2.7/lib/Doctrine/ORM/Query/ParameterTypeInferer.php).
by default, Doctrine think an ulid
is a string
and then, cast the value to string (while the value is stored as binary).
When using the Repository, you don't have such issue, because doctrine know the class and know the type of the field
Several solution for you.
- Help doctrine
->setParameter('ulid', $member->getUlid(), 'ulid')
- Convert value to a value compatible with the type inferred by doctine
->setParameter('ulid', $member->getUlid()->toBinary())
- Use Repository
$organisationMemberRepository->findOneBy(['user' => $user]);
$organisationMemberRepository->findOneBy(['user' => $user->getUlid()]);
$organisationMemberRepository->findOneByUser($user);
see symfony/symfony#39135 (comment) for full reference. Ping @warslett