From d566ad44e6ba669621367b4d3ca7637794c3d4c4 Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Wed, 28 Feb 2024 16:53:14 +0100 Subject: [PATCH 1/2] 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 ``` --- components/uid.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/uid.rst b/components/uid.rst index f27977a8296..8febdc1ff88 100644 --- a/components/uid.rst +++ b/components/uid.rst @@ -285,6 +285,7 @@ of the UUID parameters:: // src/Repository/ProductRepository.php // ... + use Doctrine\DBAL\ParameterType; use Symfony\Bridge\Doctrine\Types\UuidType; class ProductRepository extends ServiceEntityRepository @@ -300,7 +301,8 @@ of the UUID parameters:: // alternatively, you can convert it to a value compatible with // the type inferred by Doctrine - ->setParameter('user', $user->getUuid()->toBinary()) + // Note: ParameterType::BINARY is required to query PostgreSQL + ->setParameter('user', $user->getUuid()->toBinary(), ParameterType::BINARY) ; // ... From 99a0a12a4e6a82dc87e178eb930bc8c09b7955c2 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 5 Mar 2024 10:27:41 +0100 Subject: [PATCH 2/2] [Uid] Remove an unneeded comment --- components/uid.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/components/uid.rst b/components/uid.rst index 8febdc1ff88..6ae9e0f504c 100644 --- a/components/uid.rst +++ b/components/uid.rst @@ -301,7 +301,6 @@ of the UUID parameters:: // alternatively, you can convert it to a value compatible with // the type inferred by Doctrine - // Note: ParameterType::BINARY is required to query PostgreSQL ->setParameter('user', $user->getUuid()->toBinary(), ParameterType::BINARY) ;