Skip to content

Commit 7f9ea29

Browse files
committed
minor #19615 PostgreSQL setparameter() compatibility (Prometee)
This PR was submitted for the 7.0 branch but it was merged into the 6.4 branch instead. Discussion ---------- PostgreSQL setparameter() compatibility Using PostgreSQL, Doctrine will use UUID field type. If you don't specify the parameter type it will try to send a string instead of the binary content and fail with an error : ``` SQLSTATE[22021]: Character not in repertoire: 7 ERROR: invalid byte sequence for encoding \"UTF8\": ... CONTEXT: unnamed portal parameter $1 ``` Commits ------- d566ad4 PostgreSQL setparameter() compatibility
2 parents 4d1cb25 + d566ad4 commit 7f9ea29

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

components/uid.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ of the UUID parameters::
285285
// src/Repository/ProductRepository.php
286286

287287
// ...
288+
use Doctrine\DBAL\ParameterType;
288289
use Symfony\Bridge\Doctrine\Types\UuidType;
289290

290291
class ProductRepository extends ServiceEntityRepository
@@ -300,7 +301,8 @@ of the UUID parameters::
300301

301302
// alternatively, you can convert it to a value compatible with
302303
// the type inferred by Doctrine
303-
->setParameter('user', $user->getUuid()->toBinary())
304+
// Note: ParameterType::BINARY is required to query PostgreSQL
305+
->setParameter('user', $user->getUuid()->toBinary(), ParameterType::BINARY)
304306
;
305307

306308
// ...

0 commit comments

Comments
 (0)