From 61db0d6a28ed4eadc279d189e81038974981e1d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sat, 8 Oct 2022 01:30:06 +0200 Subject: [PATCH] DX: fix deprecation in dql custom function + add test --- .../Doctrine/DQL/JsonbExistsInArray.php | 2 +- .../Doctrine/DQL/JsonbExistsInArrayTest.php | 41 +++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 src/Bundle/ChillMainBundle/Tests/Doctrine/DQL/JsonbExistsInArrayTest.php diff --git a/src/Bundle/ChillMainBundle/Doctrine/DQL/JsonbExistsInArray.php b/src/Bundle/ChillMainBundle/Doctrine/DQL/JsonbExistsInArray.php index 3dbe9145c..1556753b6 100644 --- a/src/Bundle/ChillMainBundle/Doctrine/DQL/JsonbExistsInArray.php +++ b/src/Bundle/ChillMainBundle/Doctrine/DQL/JsonbExistsInArray.php @@ -27,7 +27,7 @@ class JsonbExistsInArray extends FunctionNode return sprintf( '%s ?? %s', $this->expr1->dispatch($sqlWalker), - $sqlWalker->walkInputParameter($this->expr2) + $this->expr2->dispatch($sqlWalker) ); } diff --git a/src/Bundle/ChillMainBundle/Tests/Doctrine/DQL/JsonbExistsInArrayTest.php b/src/Bundle/ChillMainBundle/Tests/Doctrine/DQL/JsonbExistsInArrayTest.php new file mode 100644 index 000000000..67c41d3d9 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Tests/Doctrine/DQL/JsonbExistsInArrayTest.php @@ -0,0 +1,41 @@ +em = self::$container->get(EntityManagerInterface::class); + } + + public function testDQLFunctionWorks() + { + $result = $this->em + ->createQuery('SELECT JSONB_EXISTS_IN_ARRAY(u.attributes, :param) FROM ' . User::class . ' u') + ->setParameter('param', 'fr') + ->getResult(); + + $this->assertIsArray($result); + } +}