From 88e20bf65b140c86e49d1aa24c50a6354e9175ac Mon Sep 17 00:00:00 2001 From: rabikor Date: Tue, 26 Nov 2024 13:42:04 +0200 Subject: [PATCH 01/14] Added processing binary binding type and default behaviour for unprocessed parameter types --- src/Persisters/Entity/BasicEntityPersister.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Persisters/Entity/BasicEntityPersister.php b/src/Persisters/Entity/BasicEntityPersister.php index 843cc0b21f3..03999dcb606 100644 --- a/src/Persisters/Entity/BasicEntityPersister.php +++ b/src/Persisters/Entity/BasicEntityPersister.php @@ -10,6 +10,7 @@ use Doctrine\Common\Collections\Order; use Doctrine\DBAL\ArrayParameterType; use Doctrine\DBAL\Connection; +use Doctrine\DBAL\Exception; use Doctrine\DBAL\LockMode; use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Platforms\AbstractPlatform; @@ -1929,7 +1930,11 @@ private function getTypes(string $field, mixed $value, ClassMetadata $class): ar return $types; } - /** @psalm-return ArrayParameterType::* */ + /** @psalm-return ArrayParameterType::* + * + * @throws QueryException + * @throws Exception + */ private function getArrayBindingType(ParameterType|int|string $type): ArrayParameterType|int { if (! $type instanceof ParameterType) { @@ -1940,6 +1945,8 @@ private function getArrayBindingType(ParameterType|int|string $type): ArrayParam ParameterType::STRING => ArrayParameterType::STRING, ParameterType::INTEGER => ArrayParameterType::INTEGER, ParameterType::ASCII => ArrayParameterType::ASCII, + ParameterType::BINARY => ArrayParameterType::BINARY, + default => throw new QueryException('Unsupported type for array parameter'), }; } From 887550f04f2aae39fa6e3e5c8092b4969ba736ac Mon Sep 17 00:00:00 2001 From: yevheniipererva Date: Tue, 10 Dec 2024 10:28:50 +0200 Subject: [PATCH 02/14] added tests to query builder with array parameter type --- phpstan-dbal3.neon | 5 -- phpstan.neon | 5 -- .../Entity/BasicEntityPersister.php | 5 +- tests/Tests/Models/CMS/CmsUser.php | 10 ++-- .../ORM/Functional/QueryParameterTest.php | 51 ++++++++++--------- 5 files changed, 37 insertions(+), 39 deletions(-) diff --git a/phpstan-dbal3.neon b/phpstan-dbal3.neon index 724fe2003f7..2085a695c56 100644 --- a/phpstan-dbal3.neon +++ b/phpstan-dbal3.neon @@ -7,11 +7,6 @@ parameters: # Symfony cache supports passing a key prefix to the clear method. - '/^Method Psr\\Cache\\CacheItemPoolInterface\:\:clear\(\) invoked with 1 parameter, 0 required\.$/' - # We can be certain that those values are not matched. - - - message: '~^Match expression does not handle remaining values:~' - path: src/Persisters/Entity/BasicEntityPersister.php - # DBAL 4 compatibility - message: '~^Method Doctrine\\ORM\\Query\\AST\\Functions\\TrimFunction::getTrimMode\(\) never returns .* so it can be removed from the return type\.$~' diff --git a/phpstan.neon b/phpstan.neon index d90ec9fe41f..5e6445e8b6d 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -7,11 +7,6 @@ parameters: # Symfony cache supports passing a key prefix to the clear method. - '/^Method Psr\\Cache\\CacheItemPoolInterface\:\:clear\(\) invoked with 1 parameter, 0 required\.$/' - # We can be certain that those values are not matched. - - - message: '~^Match expression does not handle remaining values:~' - path: src/Persisters/Entity/BasicEntityPersister.php - # DBAL 4 compatibility - message: '~^Method Doctrine\\ORM\\Query\\AST\\Functions\\TrimFunction::getTrimMode\(\) never returns .* so it can be removed from the return type\.$~' diff --git a/src/Persisters/Entity/BasicEntityPersister.php b/src/Persisters/Entity/BasicEntityPersister.php index 03999dcb606..d6378f559e0 100644 --- a/src/Persisters/Entity/BasicEntityPersister.php +++ b/src/Persisters/Entity/BasicEntityPersister.php @@ -1930,12 +1930,13 @@ private function getTypes(string $field, mixed $value, ClassMetadata $class): ar return $types; } - /** @psalm-return ArrayParameterType::* + /** + * @psalm-return ArrayParameterType::* * * @throws QueryException * @throws Exception */ - private function getArrayBindingType(ParameterType|int|string $type): ArrayParameterType|int + private function getArrayBindingType(ParameterType|int|string $type): ArrayParameterType { if (! $type instanceof ParameterType) { $type = Type::getType((string) $type)->getBindingType(); diff --git a/tests/Tests/Models/CMS/CmsUser.php b/tests/Tests/Models/CMS/CmsUser.php index c0fa4bb76b5..601d50750a9 100644 --- a/tests/Tests/Models/CMS/CmsUser.php +++ b/tests/Tests/Models/CMS/CmsUser.php @@ -29,6 +29,10 @@ class CmsUser #[GeneratedValue] public $id; + /** @var string */ + #[Column(type: 'binary', length: 50, nullable: true)] + public $reference; + /** @var string */ #[Column(type: 'string', length: 50, nullable: true)] public $status; @@ -81,9 +85,9 @@ class CmsUser public function __construct() { $this->phonenumbers = new ArrayCollection(); - $this->articles = new ArrayCollection(); - $this->groups = new ArrayCollection(); - $this->tags = new ArrayCollection(); + $this->articles = new ArrayCollection(); + $this->groups = new ArrayCollection(); + $this->tags = new ArrayCollection(); } public function getId(): int diff --git a/tests/Tests/ORM/Functional/QueryParameterTest.php b/tests/Tests/ORM/Functional/QueryParameterTest.php index e7599cea5ea..4ab9b084956 100644 --- a/tests/Tests/ORM/Functional/QueryParameterTest.php +++ b/tests/Tests/ORM/Functional/QueryParameterTest.php @@ -9,8 +9,12 @@ use Doctrine\DBAL\Types\Types; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; +use function hex2bin; +use function sprintf; + #[Group('GH-11278')] final class QueryParameterTest extends OrmFunctionalTestCase { @@ -22,15 +26,18 @@ protected function setUp(): void parent::setUp(); - $user = new CmsUser(); - $user->name = 'John Doe'; - $user->username = 'john'; - $user2 = new CmsUser(); - $user2->name = 'Jane Doe'; - $user2->username = 'jane'; - $user3 = new CmsUser(); - $user3->name = 'Just Bill'; - $user3->username = 'bill'; + $user = new CmsUser(); + $user->reference = hex2bin('1'); + $user->name = 'John Doe'; + $user->username = 'john'; + $user2 = new CmsUser(); + $user2->reference = hex2bin('2'); + $user2->name = 'Jane Doe'; + $user2->username = 'jane'; + $user3 = new CmsUser(); + $user3->reference = hex2bin('3'); + $user3->name = 'Just Bill'; + $user3->username = 'bill'; $this->_em->persist($user); $this->_em->persist($user2); @@ -94,31 +101,27 @@ public function testDbalTypeStringInQuery(): void self::assertSame([['name' => 'John Doe']], $result); } - public function testArrayParameterTypeInBuilder(): void + #[DataProvider('provideArrayParameters')] + public function testArrayParameterTypeInQuery(string $field, ArrayParameterType $type, array $values): void { $result = $this->_em->createQueryBuilder() ->from(CmsUser::class, 'u') ->select('u.name') - ->where('u.username IN (:usernames)') - ->orderBy('u.username') - ->setParameter('usernames', ['john', 'jane'], ArrayParameterType::STRING) + ->where(sprintf('u.%s IN (:values)', $field)) + ->orderBy(sprintf('u.%s', $field)) + ->setParameter('values', $values, $type) ->getQuery() ->getArrayResult(); self::assertSame([['name' => 'Jane Doe'], ['name' => 'John Doe']], $result); } - public function testArrayParameterTypeInQuery(): void + public static function provideArrayParameters(): array { - $result = $this->_em->createQueryBuilder() - ->from(CmsUser::class, 'u') - ->select('u.name') - ->where('u.username IN (:usernames)') - ->orderBy('u.username') - ->getQuery() - ->setParameter('usernames', ['john', 'jane'], ArrayParameterType::STRING) - ->getArrayResult(); - - self::assertSame([['name' => 'Jane Doe'], ['name' => 'John Doe']], $result); + return [ + 'string' => ['username', ArrayParameterType::STRING, ['john', 'jane']], + 'binary' => ['reference', ArrayParameterType::BINARY, [hex2bin('1'), hex2bin('2')]], + 'integer' => ['id' => ArrayParameterType::INTEGER, [1, 2]], + ]; } } From 21816a63e6ea4381489ec8ee90d1d8ed633f4811 Mon Sep 17 00:00:00 2001 From: yevheniipererva Date: Tue, 10 Dec 2024 10:45:13 +0200 Subject: [PATCH 03/14] returned wrong changes to test model CmsUser --- tests/Tests/Models/CMS/CmsUser.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Tests/Models/CMS/CmsUser.php b/tests/Tests/Models/CMS/CmsUser.php index 601d50750a9..08433842ca7 100644 --- a/tests/Tests/Models/CMS/CmsUser.php +++ b/tests/Tests/Models/CMS/CmsUser.php @@ -85,9 +85,9 @@ class CmsUser public function __construct() { $this->phonenumbers = new ArrayCollection(); - $this->articles = new ArrayCollection(); - $this->groups = new ArrayCollection(); - $this->tags = new ArrayCollection(); + $this->articles = new ArrayCollection(); + $this->groups = new ArrayCollection(); + $this->tags = new ArrayCollection(); } public function getId(): int From 49d1969b612ad89985317a332300bc03242e17ca Mon Sep 17 00:00:00 2001 From: yevheniipererva Date: Tue, 10 Dec 2024 10:51:29 +0200 Subject: [PATCH 04/14] fixed phpstan configs --- phpstan-dbal3.neon | 3 --- phpstan.neon | 3 --- 2 files changed, 6 deletions(-) diff --git a/phpstan-dbal3.neon b/phpstan-dbal3.neon index 2085a695c56..79f7c211622 100644 --- a/phpstan-dbal3.neon +++ b/phpstan-dbal3.neon @@ -11,9 +11,6 @@ parameters: - message: '~^Method Doctrine\\ORM\\Query\\AST\\Functions\\TrimFunction::getTrimMode\(\) never returns .* so it can be removed from the return type\.$~' path: src/Query/AST/Functions/TrimFunction.php - - - message: '~^Method Doctrine\\ORM\\Persisters\\Entity\\BasicEntityPersister\:\:getArrayBindingType\(\) never returns .* so it can be removed from the return type\.$~' - path: src/Persisters/Entity/BasicEntityPersister.php - '~^Class Doctrine\\DBAL\\Platforms\\SQLitePlatform not found\.$~' diff --git a/phpstan.neon b/phpstan.neon index 5e6445e8b6d..4dfa0bcc782 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -11,9 +11,6 @@ parameters: - message: '~^Method Doctrine\\ORM\\Query\\AST\\Functions\\TrimFunction::getTrimMode\(\) never returns .* so it can be removed from the return type\.$~' path: src/Query/AST/Functions/TrimFunction.php - - - message: '~^Method Doctrine\\ORM\\Persisters\\Entity\\BasicEntityPersister\:\:getArrayBindingType\(\) never returns .* so it can be removed from the return type\.$~' - path: src/Persisters/Entity/BasicEntityPersister.php # Compatibility with DBAL 3 # See https://github.com/doctrine/dbal/pull/3480 From 8fd08ca9a296bada0558bb3b940811131360d0e6 Mon Sep 17 00:00:00 2001 From: yevheniipererva Date: Tue, 10 Dec 2024 10:54:00 +0200 Subject: [PATCH 05/14] reverted break space to phpstan file --- phpstan-dbal3.neon | 1 + 1 file changed, 1 insertion(+) diff --git a/phpstan-dbal3.neon b/phpstan-dbal3.neon index d81dfeb55f2..9f4b42d353f 100644 --- a/phpstan-dbal3.neon +++ b/phpstan-dbal3.neon @@ -12,6 +12,7 @@ parameters: - message: '~^Method Doctrine\\ORM\\Query\\AST\\Functions\\TrimFunction::getTrimMode\(\) never returns .* so it can be removed from the return type\.$~' path: src/Query/AST/Functions/TrimFunction.php + - message: '~.*getTrimExpression.*expects int.*~' path: src/Query/AST/Functions/TrimFunction.php From 83f2898a965441d6cd1fb3229415269ada8e7b64 Mon Sep 17 00:00:00 2001 From: yevheniipererva Date: Tue, 10 Dec 2024 10:54:38 +0200 Subject: [PATCH 06/14] reverted break space to phpstan file --- phpstan-dbal3.neon | 4 ---- 1 file changed, 4 deletions(-) diff --git a/phpstan-dbal3.neon b/phpstan-dbal3.neon index 9f4b42d353f..2004c26166b 100644 --- a/phpstan-dbal3.neon +++ b/phpstan-dbal3.neon @@ -37,10 +37,6 @@ parameters: message: '#Expression on left side of \?\? is not nullable.#' path: src/Mapping/Driver/AttributeDriver.php - - - message: '~^Method Doctrine\\ORM\\Persisters\\Entity\\BasicEntityPersister\:\:getArrayBindingType\(\) never returns .* so it can be removed from the return type\.$~' - path: src/Persisters/Entity/BasicEntityPersister.php - - message: '~getTypes.*should return~' path: src/Persisters/Entity/BasicEntityPersister.php From 38ee7a8d7f2b0fe54127fa23dafb4518b0b4011d Mon Sep 17 00:00:00 2001 From: yevheniipererva Date: Tue, 10 Dec 2024 11:50:11 +0200 Subject: [PATCH 07/14] fixed tests --- .../Tests/ORM/Functional/NativeQueryTest.php | 10 +- .../ORM/Functional/QueryParameterTest.php | 64 +++++-- .../ORM/Query/CustomTreeWalkersJoinTest.php | 2 +- .../Tests/ORM/Query/CustomTreeWalkersTest.php | 8 +- .../ORM/Query/SelectSqlGenerationTest.php | 164 +++++++++--------- 5 files changed, 140 insertions(+), 108 deletions(-) diff --git a/tests/Tests/ORM/Functional/NativeQueryTest.php b/tests/Tests/ORM/Functional/NativeQueryTest.php index c9f665387b7..46746c92b67 100644 --- a/tests/Tests/ORM/Functional/NativeQueryTest.php +++ b/tests/Tests/ORM/Functional/NativeQueryTest.php @@ -475,7 +475,7 @@ public function testGenerateSelectClauseNoRenameSingleEntity(): void $selectClause = $rsm->generateSelectClause(); - $this->assertSQLEquals('u.id AS id, u.status AS status, u.username AS username, u.name AS name, u.email_id AS email_id', $selectClause); + $this->assertSQLEquals('u.id AS id, u.reference as reference, u.status AS status, u.username AS username, u.name AS name, u.email_id AS email_id', $selectClause); } #[Group('DDC-2055')] @@ -489,7 +489,7 @@ public function testGenerateSelectClauseCustomRenames(): void $selectClause = $rsm->generateSelectClause(); - $this->assertSQLEquals('u.id AS id1, u.status AS status, u.username AS username2, u.name AS name, u.email_id AS email_id', $selectClause); + $this->assertSQLEquals('u.id AS id1, u.reference as reference, u.status AS status, u.username AS username2, u.name AS name, u.email_id AS email_id', $selectClause); } #[Group('DDC-2055')] @@ -500,7 +500,7 @@ public function testGenerateSelectClauseRenameTableAlias(): void $selectClause = $rsm->generateSelectClause(['u' => 'u1']); - $this->assertSQLEquals('u1.id AS id, u1.status AS status, u1.username AS username, u1.name AS name, u1.email_id AS email_id', $selectClause); + $this->assertSQLEquals('u1.id AS id, u1.reference as reference, u1.status AS status, u1.username AS username, u1.name AS name, u1.email_id AS email_id', $selectClause); } #[Group('DDC-2055')] @@ -511,7 +511,7 @@ public function testGenerateSelectClauseIncrement(): void $selectClause = $rsm->generateSelectClause(); - $this->assertSQLEquals('u.id AS id0, u.status AS status1, u.username AS username2, u.name AS name3, u.email_id AS email_id4', $selectClause); + $this->assertSQLEquals('u.id AS id0, u.reference as reference1, u.status as status2, u.username as username3, u.name as name4, u.email_id as email_id5', $selectClause); } #[Group('DDC-2055')] @@ -520,7 +520,7 @@ public function testGenerateSelectClauseToString(): void $rsm = new ResultSetMappingBuilder($this->_em, ResultSetMappingBuilder::COLUMN_RENAMING_INCREMENT); $rsm->addRootEntityFromClassMetadata(CmsUser::class, 'u'); - $this->assertSQLEquals('u.id AS id0, u.status AS status1, u.username AS username2, u.name AS name3, u.email_id AS email_id4', (string) $rsm); + $this->assertSQLEquals('u.id AS id0, u.reference as reference1, u.status as status2, u.username as username3, u.name as name4, u.email_id as email_id5', (string) $rsm); } #[Group('DDC-3899')] diff --git a/tests/Tests/ORM/Functional/QueryParameterTest.php b/tests/Tests/ORM/Functional/QueryParameterTest.php index 4ab9b084956..8513b4ee781 100644 --- a/tests/Tests/ORM/Functional/QueryParameterTest.php +++ b/tests/Tests/ORM/Functional/QueryParameterTest.php @@ -9,12 +9,8 @@ use Doctrine\DBAL\Types\Types; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; -use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; -use function hex2bin; -use function sprintf; - #[Group('GH-11278')] final class QueryParameterTest extends OrmFunctionalTestCase { @@ -27,15 +23,15 @@ protected function setUp(): void parent::setUp(); $user = new CmsUser(); - $user->reference = hex2bin('1'); + $user->reference = '0b0001'; $user->name = 'John Doe'; $user->username = 'john'; $user2 = new CmsUser(); - $user2->reference = hex2bin('2'); + $user2->reference = '0b0010'; $user2->name = 'Jane Doe'; $user2->username = 'jane'; $user3 = new CmsUser(); - $user3->reference = hex2bin('3'); + $user3->reference = '0b0011'; $user3->name = 'Just Bill'; $user3->username = 'bill'; @@ -101,27 +97,59 @@ public function testDbalTypeStringInQuery(): void self::assertSame([['name' => 'John Doe']], $result); } - #[DataProvider('provideArrayParameters')] - public function testArrayParameterTypeInQuery(string $field, ArrayParameterType $type, array $values): void + public function testArrayParameterTypeInBuilder(): void + { + $result = $this->_em->createQueryBuilder() + ->from(CmsUser::class, 'u') + ->select('u.name') + ->where('u.username IN (:values)') + ->orderBy('u.username') + ->setParameter('values', ['john', 'jane'], ArrayParameterType::STRING) + ->getQuery() + ->getArrayResult(); + + self::assertSame([['name' => 'Jane Doe'], ['name' => 'John Doe']], $result); + } + + public function testArrayParameterTypeInQuery(): void + { + $result = $this->_em->createQueryBuilder() + ->from(CmsUser::class, 'u') + ->select('u.name') + ->where('u.username IN (:values)') + ->orderBy('u.username') + ->getQuery() + ->setParameter('values', ['john', 'jane'], ArrayParameterType::STRING) + ->getArrayResult(); + + self::assertSame([['name' => 'Jane Doe'], ['name' => 'John Doe']], $result); + } + + public function testArrayParameterTypeBinaryInBuilder(): void { $result = $this->_em->createQueryBuilder() ->from(CmsUser::class, 'u') ->select('u.name') - ->where(sprintf('u.%s IN (:values)', $field)) - ->orderBy(sprintf('u.%s', $field)) - ->setParameter('values', $values, $type) + ->where('u.reference IN (:values)') + ->orderBy('u.username') + ->setParameter('values', ['0b0001', '0b0010'], ArrayParameterType::BINARY) ->getQuery() ->getArrayResult(); self::assertSame([['name' => 'Jane Doe'], ['name' => 'John Doe']], $result); } - public static function provideArrayParameters(): array + public function testArrayParameterTypeBinaryInQuery(): void { - return [ - 'string' => ['username', ArrayParameterType::STRING, ['john', 'jane']], - 'binary' => ['reference', ArrayParameterType::BINARY, [hex2bin('1'), hex2bin('2')]], - 'integer' => ['id' => ArrayParameterType::INTEGER, [1, 2]], - ]; + $result = $this->_em->createQueryBuilder() + ->from(CmsUser::class, 'u') + ->select('u.name') + ->where('u.reference IN (:values)') + ->orderBy('u.username') + ->getQuery() + ->setParameter('values', ['0b0001', '0b0010'], ArrayParameterType::BINARY) + ->getArrayResult(); + + self::assertSame([['name' => 'Jane Doe'], ['name' => 'John Doe']], $result); } } diff --git a/tests/Tests/ORM/Query/CustomTreeWalkersJoinTest.php b/tests/Tests/ORM/Query/CustomTreeWalkersJoinTest.php index 16be0ce6ff3..914bec4d7c6 100644 --- a/tests/Tests/ORM/Query/CustomTreeWalkersJoinTest.php +++ b/tests/Tests/ORM/Query/CustomTreeWalkersJoinTest.php @@ -37,7 +37,7 @@ public function testAddsJoin(): void { $this->assertSqlGeneration( 'select u from Doctrine\Tests\Models\CMS\CmsUser u', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c1_.id AS id_4, c1_.country AS country_5, c1_.zip AS zip_6, c1_.city AS city_7, c0_.email_id AS email_id_8, c1_.user_id AS user_id_9 FROM cms_users c0_ LEFT JOIN cms_addresses c1_ ON c0_.id = c1_.user_id', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c1_.id AS id_5, c1_.country AS country_6, c1_.zip AS zip_7, c1_.city AS city_8, c0_.email_id AS email_id_9, c1_.user_id AS user_id_10 FROM cms_users c0_ LEFT JOIN cms_addresses c1_ ON c0_.id = c1_.user_id', ); } diff --git a/tests/Tests/ORM/Query/CustomTreeWalkersTest.php b/tests/Tests/ORM/Query/CustomTreeWalkersTest.php index 83e001fbdcd..999f14fb7b7 100644 --- a/tests/Tests/ORM/Query/CustomTreeWalkersTest.php +++ b/tests/Tests/ORM/Query/CustomTreeWalkersTest.php @@ -74,7 +74,7 @@ public function testSupportsQueriesWithoutWhere(): void { $this->assertSqlGeneration( 'select u from Doctrine\Tests\Models\CMS\CmsUser u', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ WHERE c0_.id = 1', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ WHERE c0_.id = 1', [CustomTreeWalker::class], ); } @@ -83,7 +83,7 @@ public function testSupportsQueriesWithMultipleConditionalExpressions(): void { $this->assertSqlGeneration( 'select u from Doctrine\Tests\Models\CMS\CmsUser u where u.name = :name or u.name = :otherName', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ WHERE (c0_.name = ? OR c0_.name = ?) AND c0_.id = 1', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ WHERE (c0_.name = ? OR c0_.name = ?) AND c0_.id = 1', [CustomTreeWalker::class], ); } @@ -92,7 +92,7 @@ public function testSupportsQueriesWithSimpleConditionalExpression(): void { $this->assertSqlGeneration( 'select u from Doctrine\Tests\Models\CMS\CmsUser u where u.name = :name', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ WHERE c0_.name = ? AND c0_.id = 1', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ WHERE c0_.name = ? AND c0_.id = 1', [CustomTreeWalker::class], ); } @@ -113,7 +113,7 @@ public function testSupportsSeveralHintsQueries(): void { $this->assertSqlGeneration( 'select u from Doctrine\Tests\Models\CMS\CmsUser u', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c1_.id AS id_4, c1_.country AS country_5, c1_.zip AS zip_6, c1_.city AS city_7, c0_.email_id AS email_id_8, c1_.user_id AS user_id_9 FROM cms_users c0_ LEFT JOIN cms_addresses c1_ ON c0_.id = c1_.user_id WHERE c0_.id = 1', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c1_.id AS id_5, c1_.country AS country_6, c1_.zip AS zip_7, c1_.city AS city_8, c0_.email_id AS email_id_9, c1_.user_id AS user_id_10 FROM cms_users c0_ LEFT JOIN cms_addresses c1_ ON c0_.id = c1_.user_id WHERE c0_.id = 1', [CustomTreeWalkerJoin::class, CustomTreeWalker::class], ); } diff --git a/tests/Tests/ORM/Query/SelectSqlGenerationTest.php b/tests/Tests/ORM/Query/SelectSqlGenerationTest.php index 02c4921c54f..42b06012d10 100644 --- a/tests/Tests/ORM/Query/SelectSqlGenerationTest.php +++ b/tests/Tests/ORM/Query/SelectSqlGenerationTest.php @@ -53,9 +53,10 @@ protected function setUp(): void public function assertSqlGeneration( string $dqlToBeTested, string $sqlToBeConfirmed, - array $queryHints = [], - array $queryParams = [], - ): void { + array $queryHints = [], + array $queryParams = [], + ): void + { $query = $this->entityManager->createQuery($dqlToBeTested); $query->setHydrationMode($this->hydrationMode); @@ -85,9 +86,10 @@ public function assertSqlGeneration( public function assertInvalidSqlGeneration( string $dqlToBeTested, string $expectedException, - array $queryHints = [], - array $queryParams = [], - ): void { + array $queryHints = [], + array $queryParams = [], + ): void + { $this->expectException($expectedException); $query = $this->entityManager->createQuery($dqlToBeTested); @@ -136,7 +138,7 @@ public function testSupportsSelectForAllFields(): void { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_', ); } @@ -168,7 +170,7 @@ public function testNotExistsExpression(): void { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE NOT EXISTS (SELECT p.phonenumber FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE p.phonenumber = 1234)', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ WHERE NOT EXISTS (SELECT c1_.phonenumber FROM cms_phonenumbers c1_ WHERE c1_.phonenumber = 1234)', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ WHERE NOT EXISTS (SELECT c1_.phonenumber FROM cms_phonenumbers c1_ WHERE c1_.phonenumber = 1234)', ); } @@ -184,7 +186,7 @@ public function testSupportsSelectUsingMultipleFromComponents(): void { $this->assertSqlGeneration( 'SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u, Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE u = p.user', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c1_.phonenumber AS phonenumber_4, c0_.email_id AS email_id_5, c1_.user_id AS user_id_6 FROM cms_users c0_, cms_phonenumbers c1_ WHERE c0_.id = c1_.user_id', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c1_.phonenumber AS phonenumber_5, c0_.email_id AS email_id_6, c1_.user_id AS user_id_7 FROM cms_users c0_, cms_phonenumbers c1_ WHERE c0_.id = c1_.user_id', ); } @@ -192,7 +194,7 @@ public function testSupportsJoinOnMultipleComponents(): void { $this->assertSqlGeneration( 'SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN Doctrine\Tests\Models\CMS\CmsPhonenumber p WITH u = p.user', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c1_.phonenumber AS phonenumber_4, c0_.email_id AS email_id_5, c1_.user_id AS user_id_6 FROM cms_users c0_ INNER JOIN cms_phonenumbers c1_ ON (c0_.id = c1_.user_id)', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c1_.phonenumber AS phonenumber_5, c0_.email_id AS email_id_6, c1_.user_id AS user_id_7 FROM cms_users c0_ INNER JOIN cms_phonenumbers c1_ ON (c0_.id = c1_.user_id)', ); } @@ -218,7 +220,7 @@ public function testSupportsSelectWithCollectionAssociationJoin(): void { $this->assertSqlGeneration( 'SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.phonenumbers p', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c1_.phonenumber AS phonenumber_4, c0_.email_id AS email_id_5, c1_.user_id AS user_id_6 FROM cms_users c0_ INNER JOIN cms_phonenumbers c1_ ON c0_.id = c1_.user_id', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c1_.phonenumber AS phonenumber_5, c0_.email_id AS email_id_6, c1_.user_id AS user_id_7 FROM cms_users c0_ INNER JOIN cms_phonenumbers c1_ ON c0_.id = c1_.user_id', ); } @@ -386,7 +388,7 @@ public function testSupportsArithmeticExpressionsInWherePart(): void { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE ((u.id + 5000) * u.id + 3) < 10000000', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ WHERE ((c0_.id + 5000) * c0_.id + 3) < 10000000', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ WHERE ((c0_.id + 5000) * c0_.id + 3) < 10000000', ); } @@ -394,7 +396,7 @@ public function testSupportsMultipleEntitiesInFromClause(): void { $this->assertSqlGeneration( 'SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u, Doctrine\Tests\Models\CMS\CmsArticle a JOIN a.user u2 WHERE u.id = u2.id', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c1_.id AS id_4, c1_.topic AS topic_5, c1_.text AS text_6, c1_.version AS version_7, c0_.email_id AS email_id_8, c1_.user_id AS user_id_9 FROM cms_users c0_, cms_articles c1_ INNER JOIN cms_users c2_ ON c1_.user_id = c2_.id WHERE c0_.id = c2_.id', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c1_.id AS id_5, c1_.topic AS topic_6, c1_.text AS text_7, c1_.version AS version_8, c0_.email_id AS email_id_9, c1_.user_id AS user_id_10 FROM cms_users c0_, cms_articles c1_ INNER JOIN cms_users c2_ ON c1_.user_id = c2_.id WHERE c0_.id = c2_.id', ); } @@ -402,7 +404,7 @@ public function testSupportsMultipleEntitiesInFromClauseUsingPathExpression(): v { $this->assertSqlGeneration( 'SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u, Doctrine\Tests\Models\CMS\CmsArticle a WHERE u.id = a.user', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c1_.id AS id_4, c1_.topic AS topic_5, c1_.text AS text_6, c1_.version AS version_7, c0_.email_id AS email_id_8, c1_.user_id AS user_id_9 FROM cms_users c0_, cms_articles c1_ WHERE c0_.id = c1_.user_id', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c1_.id AS id_5, c1_.topic AS topic_6, c1_.text AS text_7, c1_.version AS version_8, c0_.email_id AS email_id_9, c1_.user_id AS user_id_10 FROM cms_users c0_, cms_articles c1_ WHERE c0_.id = c1_.user_id', ); } @@ -423,11 +425,11 @@ public function testSupportsJoinAndWithClauseRestriction(): void { $this->assertSqlGeneration( "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a WITH a.topic LIKE '%foo%'", - "SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ LEFT JOIN cms_articles c1_ ON c0_.id = c1_.user_id AND (c1_.topic LIKE '%foo%')", + "SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ LEFT JOIN cms_articles c1_ ON c0_.id = c1_.user_id AND (c1_.topic LIKE '%foo%')", ); $this->assertSqlGeneration( "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles a WITH a.topic LIKE '%foo%'", - "SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ INNER JOIN cms_articles c1_ ON c0_.id = c1_.user_id AND (c1_.topic LIKE '%foo%')", + "SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ INNER JOIN cms_articles c1_ ON c0_.id = c1_.user_id AND (c1_.topic LIKE '%foo%')", ); } @@ -569,7 +571,7 @@ public function testSupportsMultipleValuedInExpressionInWherePart(): void { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id IN (1, 2)', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ WHERE c0_.id IN (1, 2)', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ WHERE c0_.id IN (1, 2)', ); } @@ -577,7 +579,7 @@ public function testSupportsNotInExpressionInWherePart(): void { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE :id NOT IN (1)', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ WHERE ? NOT IN (1)', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ WHERE ? NOT IN (1)', ); } @@ -658,7 +660,7 @@ public function testSubqueriesInComparisonExpression(): void { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE (u.id >= (SELECT u2.id FROM Doctrine\Tests\Models\CMS\CmsUser u2 WHERE u2.name = :name)) AND (u.id <= (SELECT u3.id FROM Doctrine\Tests\Models\CMS\CmsUser u3 WHERE u3.name = :name))', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ WHERE (c0_.id >= (SELECT c1_.id FROM cms_users c1_ WHERE c1_.name = ?)) AND (c0_.id <= (SELECT c2_.id FROM cms_users c2_ WHERE c2_.name = ?))', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ WHERE (c0_.id >= (SELECT c1_.id FROM cms_users c1_ WHERE c1_.name = ?)) AND (c0_.id <= (SELECT c2_.id FROM cms_users c2_ WHERE c2_.name = ?))', ); } @@ -667,7 +669,7 @@ public function testSupportsMemberOfExpressionOneToMany(): void // "Get all users who have $phone as a phonenumber." (*cough* doesnt really make sense...) $q = $this->entityManager->createQuery('SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE :param MEMBER OF u.phonenumbers'); - $phone = new CmsPhonenumber(); + $phone = new CmsPhonenumber(); $phone->phonenumber = 101; $q->setParameter('param', $phone); @@ -682,7 +684,7 @@ public function testSupportsMemberOfExpressionManyToMany(): void // "Get all users who are members of $group." $q = $this->entityManager->createQuery('SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE :param MEMBER OF u.groups'); - $group = new CmsGroup(); + $group = new CmsGroup(); $group->id = 101; $q->setParameter('param', $group); @@ -696,9 +698,9 @@ public function testSupportsMemberOfExpressionManyToManyParameterArray(): void { $q = $this->entityManager->createQuery('SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE :param MEMBER OF u.groups'); - $group = new CmsGroup(); - $group->id = 101; - $group2 = new CmsGroup(); + $group = new CmsGroup(); + $group->id = 101; + $group2 = new CmsGroup(); $group2->id = 105; $q->setParameter('param', [$group, $group2]); @@ -712,7 +714,7 @@ public function testSupportsMemberOfExpressionSelfReferencing(): void { // "Get all persons who have $person as a friend." // Tough one: Many-many self-referencing ("friends") with class table inheritance - $q = $this->entityManager->createQuery('SELECT p FROM Doctrine\Tests\Models\Company\CompanyPerson p WHERE :param MEMBER OF p.friends'); + $q = $this->entityManager->createQuery('SELECT p FROM Doctrine\Tests\Models\Company\CompanyPerson p WHERE :param MEMBER OF p.friends'); $person = new CompanyPerson(); $this->entityManager->getClassMetadata($person::class)->setIdentifierValues($person, ['id' => 101]); $q->setParameter('param', $person); @@ -765,8 +767,8 @@ public function testSupportsCurrentTimestampFunction(): void public function testExistsExpressionInWhereCorrelatedSubqueryAssocCondition(): void { $this->assertSqlGeneration( - // DQL - // The result of this query consists of all employees whose spouses are also employees. + // DQL + // The result of this query consists of all employees whose spouses are also employees. 'SELECT DISTINCT emp FROM Doctrine\Tests\Models\CMS\CmsEmployee emp WHERE EXISTS ( SELECT spouseEmp @@ -780,8 +782,8 @@ public function testExistsExpressionInWhereCorrelatedSubqueryAssocCondition(): v public function testExistsExpressionWithSimpleSelectReturningScalar(): void { $this->assertSqlGeneration( - // DQL - // The result of this query consists of all employees whose spouses are also employees. + // DQL + // The result of this query consists of all employees whose spouses are also employees. 'SELECT DISTINCT emp FROM Doctrine\Tests\Models\CMS\CmsEmployee emp WHERE EXISTS ( SELECT 1 @@ -798,7 +800,7 @@ public function testLimitFromQueryClass(): void ->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u') ->setMaxResults(10); - self::assertEquals('SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ LIMIT 10', $q->getSql()); + self::assertEquals('SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ LIMIT 10', $q->getSql()); } public function testLimitAndOffsetFromQueryClass(): void @@ -812,8 +814,8 @@ public function testLimitAndOffsetFromQueryClass(): void self::assertThat( $q->getSql(), self::logicalOr( - self::identicalTo('SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ LIMIT 10'), - self::identicalTo('SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ LIMIT 10 OFFSET 0'), + self::identicalTo('SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ LIMIT 10'), + self::identicalTo('SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ LIMIT 10 OFFSET 0'), ), ); } @@ -822,7 +824,7 @@ public function testSizeFunction(): void { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE SIZE(u.phonenumbers) > 1', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ WHERE (SELECT COUNT(*) FROM cms_phonenumbers c1_ WHERE c1_.user_id = c0_.id) > 1', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ WHERE (SELECT COUNT(*) FROM cms_phonenumbers c1_ WHERE c1_.user_id = c0_.id) > 1', ); } @@ -830,7 +832,7 @@ public function testSizeFunctionSupportsManyToMany(): void { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE SIZE(u.groups) > 1', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ WHERE (SELECT COUNT(*) FROM cms_users_groups c1_ WHERE c1_.user_id = c0_.id) > 1', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ WHERE (SELECT COUNT(*) FROM cms_users_groups c1_ WHERE c1_.user_id = c0_.id) > 1', ); } @@ -838,11 +840,11 @@ public function testEmptyCollectionComparisonExpression(): void { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.phonenumbers IS EMPTY', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ WHERE (SELECT COUNT(*) FROM cms_phonenumbers c1_ WHERE c1_.user_id = c0_.id) = 0', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ WHERE (SELECT COUNT(*) FROM cms_phonenumbers c1_ WHERE c1_.user_id = c0_.id) = 0', ); $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.phonenumbers IS NOT EMPTY', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ WHERE (SELECT COUNT(*) FROM cms_phonenumbers c1_ WHERE c1_.user_id = c0_.id) > 0', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ WHERE (SELECT COUNT(*) FROM cms_phonenumbers c1_ WHERE c1_.user_id = c0_.id) > 0', ); } @@ -850,7 +852,7 @@ public function testNestedExpressions(): void { $this->assertSqlGeneration( 'select u from Doctrine\Tests\Models\CMS\CmsUser u where u.id > 10 and u.id < 42 and ((u.id * 2) > 5)', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ WHERE c0_.id > 10 AND c0_.id < 42 AND ((c0_.id * 2) > 5)', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ WHERE c0_.id > 10 AND c0_.id < 42 AND ((c0_.id * 2) > 5)', ); } @@ -858,7 +860,7 @@ public function testNestedExpressions2(): void { $this->assertSqlGeneration( 'select u from Doctrine\Tests\Models\CMS\CmsUser u where (u.id > 10) and (u.id < 42 and ((u.id * 2) > 5)) or u.id <> 42', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ WHERE (c0_.id > 10) AND (c0_.id < 42 AND ((c0_.id * 2) > 5)) OR c0_.id <> 42', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ WHERE (c0_.id > 10) AND (c0_.id < 42 AND ((c0_.id * 2) > 5)) OR c0_.id <> 42', ); } @@ -866,7 +868,7 @@ public function testNestedExpressions3(): void { $this->assertSqlGeneration( 'select u from Doctrine\Tests\Models\CMS\CmsUser u where (u.id > 10) and (u.id between 1 and 10 or u.id in (1, 2, 3, 4, 5))', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ WHERE (c0_.id > 10) AND (c0_.id BETWEEN 1 AND 10 OR c0_.id IN (1, 2, 3, 4, 5))', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ WHERE (c0_.id > 10) AND (c0_.id BETWEEN 1 AND 10 OR c0_.id IN (1, 2, 3, 4, 5))', ); } @@ -874,7 +876,7 @@ public function testOrderByCollectionAssociationSize(): void { $this->assertSqlGeneration( 'select u, size(u.articles) as numArticles from Doctrine\Tests\Models\CMS\CmsUser u order by numArticles', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, (SELECT COUNT(*) FROM cms_articles c1_ WHERE c1_.user_id = c0_.id) AS sclr_4, c0_.email_id AS email_id_5 FROM cms_users c0_ ORDER BY sclr_4 ASC', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, (SELECT COUNT(*) FROM cms_articles c1_ WHERE c1_.user_id = c0_.id) AS sclr_5, c0_.email_id AS email_id_6 FROM cms_users c0_ ORDER BY sclr_5 ASC', ); } @@ -946,7 +948,7 @@ public function testSingleValuedAssociationNullCheckOnInverseSide(): void { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.address a WHERE a.id IS NULL', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ LEFT JOIN cms_addresses c1_ ON c0_.id = c1_.user_id WHERE c1_.id IS NULL', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ LEFT JOIN cms_addresses c1_ ON c0_.id = c1_.user_id WHERE c1_.id IS NULL', ); } @@ -978,7 +980,7 @@ public function testStringFunctionLikeExpression(): void ); $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a WITH a.topic LIKE u.name', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ LEFT JOIN cms_articles c1_ ON c0_.id = c1_.user_id AND (c1_.topic LIKE c0_.name)', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ LEFT JOIN cms_articles c1_ ON c0_.id = c1_.user_id AND (c1_.topic LIKE c0_.name)', ); } @@ -996,7 +998,7 @@ public function testStringFunctionNotLikeExpression(): void ); $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a WITH a.topic NOT LIKE u.name', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ LEFT JOIN cms_articles c1_ ON c0_.id = c1_.user_id AND (c1_.topic NOT LIKE c0_.name)', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ LEFT JOIN cms_articles c1_ ON c0_.id = c1_.user_id AND (c1_.topic NOT LIKE c0_.name)', ); } @@ -1027,7 +1029,7 @@ public function testPessimisticWriteLockQueryHint(): void $this->assertSqlGeneration( "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 'gblanco'", - "SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ WHERE c0_.username = 'gblanco' FOR UPDATE", + "SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ WHERE c0_.username = 'gblanco' FOR UPDATE", [ORMQuery::HINT_LOCK_MODE => LockMode::PESSIMISTIC_WRITE], ); } @@ -1040,7 +1042,7 @@ public function testPessimisticReadLockQueryHintPostgreSql(): void $this->assertSqlGeneration( "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 'gblanco'", - "SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ WHERE c0_.username = 'gblanco' FOR SHARE", + "SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ WHERE c0_.username = 'gblanco' FOR SHARE", [ORMQuery::HINT_LOCK_MODE => LockMode::PESSIMISTIC_READ], ); } @@ -1051,7 +1053,7 @@ public function testLockModeNoneQueryHint(): void { $this->assertSqlGeneration( "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 'gblanco'", - "SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ WHERE c0_.username = 'gblanco'", + "SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ WHERE c0_.username = 'gblanco'", [ORMQuery::HINT_LOCK_MODE => LockMode::NONE], ); } @@ -1061,7 +1063,7 @@ public function testSupportSelectWithMoreThan10InputParameters(): void { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1 OR u.id = ?2 OR u.id = ?3 OR u.id = ?4 OR u.id = ?5 OR u.id = ?6 OR u.id = ?7 OR u.id = ?8 OR u.id = ?9 OR u.id = ?10 OR u.id = ?11', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ WHERE c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ?', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ WHERE c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ?', ); } @@ -1073,7 +1075,7 @@ public function testPessimisticReadLockQueryHintMySql(): void $this->assertSqlGeneration( "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 'gblanco'", - "SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ WHERE c0_.username = 'gblanco' LOCK IN SHARE MODE", + "SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ WHERE c0_.username = 'gblanco' LOCK IN SHARE MODE", [ORMQuery::HINT_LOCK_MODE => LockMode::PESSIMISTIC_READ], ); } @@ -1086,7 +1088,7 @@ public function testPessimisticReadLockQueryHintOracle(): void $this->assertSqlGeneration( "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 'gblanco'", - "SELECT c0_.id AS ID_0, c0_.status AS STATUS_1, c0_.username AS USERNAME_2, c0_.name AS NAME_3, c0_.email_id AS EMAIL_ID_4 FROM cms_users c0_ WHERE c0_.username = 'gblanco' FOR UPDATE", + "SELECT c0_.id AS ID_0, c0_.reference AS REFERENCE_1, c0_.status AS STATUS_2, c0_.username AS USERNAME_3, c0_.name AS NAME_4, c0_.email_id AS EMAIL_ID_5 FROM cms_users c0_ WHERE c0_.username = 'gblanco' FOR UPDATE", [ORMQuery::HINT_LOCK_MODE => LockMode::PESSIMISTIC_READ], ); } @@ -1178,7 +1180,7 @@ public function testSubSelectAliasesFromOuterQuery(): void { $this->assertSqlGeneration( 'SELECT uo, (SELECT ui.name FROM Doctrine\Tests\Models\CMS\CmsUser ui WHERE ui.id = uo.id) AS bar FROM Doctrine\Tests\Models\CMS\CmsUser uo', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, (SELECT c1_.name FROM cms_users c1_ WHERE c1_.id = c0_.id) AS sclr_4, c0_.email_id AS email_id_5 FROM cms_users c0_', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, (SELECT c1_.name FROM cms_users c1_ WHERE c1_.id = c0_.id) AS sclr_5, c0_.email_id AS email_id_6 FROM cms_users c0_', ); } @@ -1186,7 +1188,7 @@ public function testSubSelectAliasesFromOuterQueryWithSubquery(): void { $this->assertSqlGeneration( 'SELECT uo, (SELECT ui.name FROM Doctrine\Tests\Models\CMS\CmsUser ui WHERE ui.id = uo.id AND ui.name IN (SELECT uii.name FROM Doctrine\Tests\Models\CMS\CmsUser uii)) AS bar FROM Doctrine\Tests\Models\CMS\CmsUser uo', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, (SELECT c1_.name FROM cms_users c1_ WHERE c1_.id = c0_.id AND c1_.name IN (SELECT c2_.name FROM cms_users c2_)) AS sclr_4, c0_.email_id AS email_id_5 FROM cms_users c0_', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, (SELECT c1_.name FROM cms_users c1_ WHERE c1_.id = c0_.id AND c1_.name IN (SELECT c2_.name FROM cms_users c2_)) AS sclr_5, c0_.email_id AS email_id_6 FROM cms_users c0_', ); } @@ -1194,7 +1196,7 @@ public function testSubSelectAliasesFromOuterQueryReuseInWhereClause(): void { $this->assertSqlGeneration( 'SELECT uo, (SELECT ui.name FROM Doctrine\Tests\Models\CMS\CmsUser ui WHERE ui.id = uo.id) AS bar FROM Doctrine\Tests\Models\CMS\CmsUser uo WHERE bar = ?0', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, (SELECT c1_.name FROM cms_users c1_ WHERE c1_.id = c0_.id) AS sclr_4, c0_.email_id AS email_id_5 FROM cms_users c0_ WHERE sclr_4 = ?', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, (SELECT c1_.name FROM cms_users c1_ WHERE c1_.id = c0_.id) AS sclr_5, c0_.email_id AS email_id_6 FROM cms_users c0_ WHERE sclr_5 = ?', ); } @@ -1550,12 +1552,12 @@ public function testSelectWithArithmeticExpressionBeforeField(): void ); } - #[Group('DDC-1430')] + #[Group('DDC-1430')] public function testGroupByAllFieldsWhenObjectHasForeignKeys(): void { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u GROUP BY u', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ GROUP BY c0_.id, c0_.status, c0_.username, c0_.name, c0_.email_id', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ GROUP BY c0_.id, c0_.reference, c0_.status, c0_.username, c0_.name, c0_.email_id', ); $this->assertSqlGeneration( @@ -1569,7 +1571,7 @@ public function testGroupBySupportsResultVariable(): void { $this->assertSqlGeneration( 'SELECT u, u.status AS st FROM Doctrine\Tests\Models\CMS\CmsUser u GROUP BY st', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.status AS status_4, c0_.email_id AS email_id_5 FROM cms_users c0_ GROUP BY c0_.status', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.status AS status_5, c0_.email_id AS email_id_6 FROM cms_users c0_ GROUP BY c0_.status', ); } @@ -1578,7 +1580,7 @@ public function testGroupBySupportsIdentificationVariable(): void { $this->assertSqlGeneration( 'SELECT u AS user FROM Doctrine\Tests\Models\CMS\CmsUser u GROUP BY user', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ GROUP BY id_0, status_1, username_2, name_3', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ GROUP BY id_0, reference_1, status_2, username_3, name_4', ); } @@ -1587,7 +1589,7 @@ public function testSupportsBitComparison(): void { $this->assertSqlGeneration( 'SELECT BIT_OR(4,2), BIT_AND(4,2), u FROM Doctrine\Tests\Models\CMS\CmsUser u', - 'SELECT (4 | 2) AS sclr_0, (4 & 2) AS sclr_1, c0_.id AS id_2, c0_.status AS status_3, c0_.username AS username_4, c0_.name AS name_5, c0_.email_id AS email_id_6 FROM cms_users c0_', + 'SELECT (4 | 2) AS sclr_0, (4 & 2) AS sclr_1, c0_.id AS id_2, c0_.reference AS reference_3, c0_.status AS status_4, c0_.username AS username_5, c0_.name AS name_6, c0_.email_id AS email_id_7 FROM cms_users c0_', ); $this->assertSqlGeneration( 'SELECT BIT_OR(u.id,2), BIT_AND(u.id,2) FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE BIT_OR(u.id,2) > 0', @@ -1608,15 +1610,15 @@ public function testParenthesesOnTheLeftHandOfComparison(): void { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u where ( (u.id + u.id) * u.id ) > 100', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ WHERE ((c0_.id + c0_.id) * c0_.id) > 100', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ WHERE ((c0_.id + c0_.id) * c0_.id) > 100', ); $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u where (u.id + u.id) * u.id > 100', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ WHERE (c0_.id + c0_.id) * c0_.id > 100', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ WHERE (c0_.id + c0_.id) * c0_.id > 100', ); $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u where 100 < (u.id + u.id) * u.id ', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ WHERE 100 < (c0_.id + c0_.id) * c0_.id', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ WHERE 100 < (c0_.id + c0_.id) * c0_.id', ); } @@ -1633,27 +1635,27 @@ public function testSupportsSubSqlFunction(): void { $this->assertSqlGeneration( 'SELECT u1 FROM Doctrine\Tests\Models\CMS\CmsUser u1 WHERE u1.name IN ( SELECT TRIM(u2.name) FROM Doctrine\Tests\Models\CMS\CmsUser u2 )', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ WHERE c0_.name IN (SELECT TRIM(c1_.name) AS sclr_5 FROM cms_users c1_)', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ WHERE c0_.name IN (SELECT TRIM(c1_.name) AS sclr_6 FROM cms_users c1_)', ); $this->assertSqlGeneration( 'SELECT u1 FROM Doctrine\Tests\Models\CMS\CmsUser u1 WHERE u1.name IN ( SELECT TRIM(u2.name) FROM Doctrine\Tests\Models\CMS\CmsUser u2 WHERE LOWER(u2.name) LIKE \'%fabio%\')', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ WHERE c0_.name IN (SELECT TRIM(c1_.name) AS sclr_5 FROM cms_users c1_ WHERE LOWER(c1_.name) LIKE \'%fabio%\')', + "SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ WHERE c0_.name IN (SELECT TRIM(c1_.name) AS sclr_6 FROM cms_users c1_ WHERE LOWER(c1_.name) LIKE '%fabio%')", ); $this->assertSqlGeneration( 'SELECT u1 FROM Doctrine\Tests\Models\CMS\CmsUser u1 WHERE u1.email IN ( SELECT TRIM(IDENTITY(u2.email)) FROM Doctrine\Tests\Models\CMS\CmsUser u2 )', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ WHERE c0_.email_id IN (SELECT TRIM(c1_.email_id) AS sclr_5 FROM cms_users c1_)', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ WHERE c0_.email_id IN (SELECT TRIM(c1_.email_id) AS sclr_6 FROM cms_users c1_)', ); $this->assertSqlGeneration( 'SELECT u1 FROM Doctrine\Tests\Models\CMS\CmsUser u1 WHERE u1.email IN ( SELECT IDENTITY(u2.email) FROM Doctrine\Tests\Models\CMS\CmsUser u2 )', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ WHERE c0_.email_id IN (SELECT c1_.email_id AS sclr_5 FROM cms_users c1_)', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ WHERE c0_.email_id IN (SELECT c1_.email_id AS sclr_6 FROM cms_users c1_)', ); $this->assertSqlGeneration( 'SELECT u1 FROM Doctrine\Tests\Models\CMS\CmsUser u1 WHERE COUNT(u1.id) = ( SELECT SUM(u2.id) FROM Doctrine\Tests\Models\CMS\CmsUser u2 )', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ WHERE COUNT(c0_.id) = (SELECT SUM(c1_.id) AS sclr_5 FROM cms_users c1_)', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ WHERE COUNT(c0_.id) = (SELECT SUM(c1_.id) AS sclr_6 FROM cms_users c1_)', ); $this->assertSqlGeneration( 'SELECT u1 FROM Doctrine\Tests\Models\CMS\CmsUser u1 WHERE COUNT(u1.id) <= ( SELECT SUM(u2.id) + COUNT(u2.email) FROM Doctrine\Tests\Models\CMS\CmsUser u2 )', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ WHERE COUNT(c0_.id) <= (SELECT SUM(c1_.id) + COUNT(c1_.email_id) AS sclr_5 FROM cms_users c1_)', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ WHERE COUNT(c0_.id) <= (SELECT SUM(c1_.id) + COUNT(c1_.email_id) AS sclr_6 FROM cms_users c1_)', ); } @@ -1696,37 +1698,37 @@ public function testWhereFunctionIsNullComparisonExpression(): void { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE IDENTITY(u.email) IS NULL', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ WHERE c0_.email_id IS NULL', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ WHERE c0_.email_id IS NULL', ); $this->assertSqlGeneration( "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE NULLIF(u.name, 'FabioBatSilva') IS NULL AND IDENTITY(u.email) IS NOT NULL", - "SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ WHERE NULLIF(c0_.name, 'FabioBatSilva') IS NULL AND c0_.email_id IS NOT NULL", + "SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ WHERE NULLIF(c0_.name, 'FabioBatSilva') IS NULL AND c0_.email_id IS NOT NULL", ); $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE IDENTITY(u.email) IS NOT NULL', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ WHERE c0_.email_id IS NOT NULL', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ WHERE c0_.email_id IS NOT NULL', ); $this->assertSqlGeneration( "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE NULLIF(u.name, 'FabioBatSilva') IS NOT NULL", - "SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ WHERE NULLIF(c0_.name, 'FabioBatSilva') IS NOT NULL", + "SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ WHERE NULLIF(c0_.name, 'FabioBatSilva') IS NOT NULL", ); $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE COALESCE(u.name, u.id) IS NOT NULL', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ WHERE COALESCE(c0_.name, c0_.id) IS NOT NULL', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ WHERE COALESCE(c0_.name, c0_.id) IS NOT NULL', ); $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE COALESCE(u.id, IDENTITY(u.email)) IS NOT NULL', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ WHERE COALESCE(c0_.id, c0_.email_id) IS NOT NULL', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ WHERE COALESCE(c0_.id, c0_.email_id) IS NOT NULL', ); $this->assertSqlGeneration( "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE COALESCE(IDENTITY(u.email), NULLIF(u.name, 'FabioBatSilva')) IS NOT NULL", - "SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ WHERE COALESCE(c0_.email_id, NULLIF(c0_.name, 'FabioBatSilva')) IS NOT NULL", + "SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ WHERE COALESCE(c0_.email_id, NULLIF(c0_.name, 'FabioBatSilva')) IS NOT NULL", ); } @@ -1800,15 +1802,15 @@ public function testOrderByClauseSupportsSimpleArithmeticExpression(): void { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY u.id + 1 ', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ ORDER BY c0_.id + 1 ASC', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ ORDER BY c0_.id + 1 ASC', ); $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY ( ( (u.id + 1) * (u.id - 1) ) / 2)', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ ORDER BY (((c0_.id + 1) * (c0_.id - 1)) / 2) ASC', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ ORDER BY (((c0_.id + 1) * (c0_.id - 1)) / 2) ASC', ); $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY ((u.id + 5000) * u.id + 3) ', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ ORDER BY ((c0_.id + 5000) * c0_.id + 3) ASC', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ ORDER BY ((c0_.id + 5000) * c0_.id + 3) ASC', ); } @@ -1816,7 +1818,7 @@ public function testOrderByClauseSupportsFunction(): void { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY CONCAT(u.username, u.name) ', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ ORDER BY c0_.username || c0_.name ASC', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, c0_.email_id AS email_id_5 FROM cms_users c0_ ORDER BY c0_.username || c0_.name ASC', ); } @@ -1956,7 +1958,7 @@ public function testSupportsMoreThanTwoParametersInConcatFunction(): void ); } - #[Group('DDC-2188')] + #[Group('DDC-2188')] public function testArithmeticPriority(): void { $this->assertSqlGeneration( @@ -2102,7 +2104,7 @@ public function testHavingSupportResultVariableNullComparisonExpression(): void { $this->assertSqlGeneration( 'SELECT u AS user, SUM(a.id) AS score FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN Doctrine\Tests\Models\CMS\CmsAddress a WITH a.user = u GROUP BY u HAVING score IS NOT NULL AND score >= 5', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, SUM(c1_.id) AS sclr_4, c0_.email_id AS email_id_5 FROM cms_users c0_ LEFT JOIN cms_addresses c1_ ON (c1_.user_id = c0_.id) GROUP BY c0_.id, c0_.status, c0_.username, c0_.name, c0_.email_id HAVING sclr_4 IS NOT NULL AND sclr_4 >= 5', + 'SELECT c0_.id AS id_0, c0_.reference AS reference_1, c0_.status AS status_2, c0_.username AS username_3, c0_.name AS name_4, SUM(c1_.id) AS sclr_5, c0_.email_id AS email_id_6 FROM cms_users c0_ LEFT JOIN cms_addresses c1_ ON (c1_.user_id = c0_.id) GROUP BY c0_.id, c0_.reference, c0_.status, c0_.username, c0_.name, c0_.email_id HAVING sclr_5 IS NOT NULL AND sclr_5 >= 5', ); } @@ -2157,6 +2159,7 @@ public function parse(Parser $parser): void $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } + #[Entity] class DDC1384Model { @@ -2180,7 +2183,8 @@ class DDC1474Entity public function __construct( #[Column(type: 'float')] private string $value, - ) { + ) + { } public function getId(): int From 5acde884e1e56a892775bd4e0e3219c089dd61db Mon Sep 17 00:00:00 2001 From: yevheniipererva Date: Tue, 10 Dec 2024 12:03:53 +0200 Subject: [PATCH 08/14] cs fixed --- .../ORM/Query/SelectSqlGenerationTest.php | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/tests/Tests/ORM/Query/SelectSqlGenerationTest.php b/tests/Tests/ORM/Query/SelectSqlGenerationTest.php index 42b06012d10..679b3c008f1 100644 --- a/tests/Tests/ORM/Query/SelectSqlGenerationTest.php +++ b/tests/Tests/ORM/Query/SelectSqlGenerationTest.php @@ -53,10 +53,9 @@ protected function setUp(): void public function assertSqlGeneration( string $dqlToBeTested, string $sqlToBeConfirmed, - array $queryHints = [], - array $queryParams = [], - ): void - { + array $queryHints = [], + array $queryParams = [], + ): void { $query = $this->entityManager->createQuery($dqlToBeTested); $query->setHydrationMode($this->hydrationMode); @@ -86,10 +85,9 @@ public function assertSqlGeneration( public function assertInvalidSqlGeneration( string $dqlToBeTested, string $expectedException, - array $queryHints = [], - array $queryParams = [], - ): void - { + array $queryHints = [], + array $queryParams = [], + ): void { $this->expectException($expectedException); $query = $this->entityManager->createQuery($dqlToBeTested); @@ -669,7 +667,7 @@ public function testSupportsMemberOfExpressionOneToMany(): void // "Get all users who have $phone as a phonenumber." (*cough* doesnt really make sense...) $q = $this->entityManager->createQuery('SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE :param MEMBER OF u.phonenumbers'); - $phone = new CmsPhonenumber(); + $phone = new CmsPhonenumber(); $phone->phonenumber = 101; $q->setParameter('param', $phone); @@ -684,7 +682,7 @@ public function testSupportsMemberOfExpressionManyToMany(): void // "Get all users who are members of $group." $q = $this->entityManager->createQuery('SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE :param MEMBER OF u.groups'); - $group = new CmsGroup(); + $group = new CmsGroup(); $group->id = 101; $q->setParameter('param', $group); @@ -698,9 +696,9 @@ public function testSupportsMemberOfExpressionManyToManyParameterArray(): void { $q = $this->entityManager->createQuery('SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE :param MEMBER OF u.groups'); - $group = new CmsGroup(); - $group->id = 101; - $group2 = new CmsGroup(); + $group = new CmsGroup(); + $group->id = 101; + $group2 = new CmsGroup(); $group2->id = 105; $q->setParameter('param', [$group, $group2]); @@ -714,7 +712,7 @@ public function testSupportsMemberOfExpressionSelfReferencing(): void { // "Get all persons who have $person as a friend." // Tough one: Many-many self-referencing ("friends") with class table inheritance - $q = $this->entityManager->createQuery('SELECT p FROM Doctrine\Tests\Models\Company\CompanyPerson p WHERE :param MEMBER OF p.friends'); + $q = $this->entityManager->createQuery('SELECT p FROM Doctrine\Tests\Models\Company\CompanyPerson p WHERE :param MEMBER OF p.friends'); $person = new CompanyPerson(); $this->entityManager->getClassMetadata($person::class)->setIdentifierValues($person, ['id' => 101]); $q->setParameter('param', $person); @@ -2183,8 +2181,7 @@ class DDC1474Entity public function __construct( #[Column(type: 'float')] private string $value, - ) - { + ) { } public function getId(): int From c409377f9b135b54d3508d2b5e58d7197e96c875 Mon Sep 17 00:00:00 2001 From: yevheniipererva Date: Tue, 10 Dec 2024 12:53:29 +0200 Subject: [PATCH 09/14] return types fixed --- src/Persisters/Entity/BasicEntityPersister.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Persisters/Entity/BasicEntityPersister.php b/src/Persisters/Entity/BasicEntityPersister.php index 5dad4ba0e95..45dae839498 100644 --- a/src/Persisters/Entity/BasicEntityPersister.php +++ b/src/Persisters/Entity/BasicEntityPersister.php @@ -1936,7 +1936,7 @@ private function getTypes(string $field, mixed $value, ClassMetadata $class): ar * @throws QueryException * @throws Exception */ - private function getArrayBindingType(ParameterType|int|string $type): ArrayParameterType + private function getArrayBindingType(ParameterType|int|string $type): ArrayParameterType|int { if (! $type instanceof ParameterType) { $type = Type::getType((string) $type)->getBindingType(); From f564b56a182e8e2387b6ecc17ff9862263adf017 Mon Sep 17 00:00:00 2001 From: yevheniipererva Date: Tue, 10 Dec 2024 12:54:28 +0200 Subject: [PATCH 10/14] return types fixed --- phpstan-dbal3.neon | 4 ++++ phpstan.neon | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/phpstan-dbal3.neon b/phpstan-dbal3.neon index 2004c26166b..9f4b42d353f 100644 --- a/phpstan-dbal3.neon +++ b/phpstan-dbal3.neon @@ -37,6 +37,10 @@ parameters: message: '#Expression on left side of \?\? is not nullable.#' path: src/Mapping/Driver/AttributeDriver.php + - + message: '~^Method Doctrine\\ORM\\Persisters\\Entity\\BasicEntityPersister\:\:getArrayBindingType\(\) never returns .* so it can be removed from the return type\.$~' + path: src/Persisters/Entity/BasicEntityPersister.php + - message: '~getTypes.*should return~' path: src/Persisters/Entity/BasicEntityPersister.php diff --git a/phpstan.neon b/phpstan.neon index 604da821b91..86846e915e0 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -12,6 +12,10 @@ parameters: message: '~^Method Doctrine\\ORM\\Query\\AST\\Functions\\TrimFunction::getTrimMode\(\) never returns .* so it can be removed from the return type\.$~' path: src/Query/AST/Functions/TrimFunction.php + - + message: '~^Method Doctrine\\ORM\\Persisters\\Entity\\BasicEntityPersister\:\:getArrayBindingType\(\) never returns .* so it can be removed from the return type\.$~' + path: src/Persisters/Entity/BasicEntityPersister.php + # Compatibility with DBAL 3 # See https://github.com/doctrine/dbal/pull/3480 - From daa875c7dae590b739db3c74526d0f2d955c51d6 Mon Sep 17 00:00:00 2001 From: yevheniipererva Date: Wed, 11 Dec 2024 10:23:37 +0200 Subject: [PATCH 11/14] fixed mysql schema tests --- tests/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php b/tests/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php index cbfc491d654..70a4da088d8 100644 --- a/tests/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php +++ b/tests/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php @@ -53,9 +53,9 @@ public function testGetCreateSchemaSql(): void self::assertEquals('CREATE TABLE cms_groups (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(50) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB', $sql[0]); self::assertThat($sql[1], self::logicalOr( // DBAL 3 - self::equalTo('CREATE TABLE cms_users (id INT AUTO_INCREMENT NOT NULL, email_id INT DEFAULT NULL, status VARCHAR(50) DEFAULT NULL, username VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_3AF03EC5F85E0677 (username), UNIQUE INDEX UNIQ_3AF03EC5A832C1C9 (email_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'), + self::equalTo('CREATE TABLE cms_users (id INT AUTO_INCREMENT NOT NULL, email_id INT DEFAULT NULL, reference VARBINARY(50) DEFAULT NULL, status VARCHAR(50) DEFAULT NULL, username VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_3AF03EC5F85E0677 (username), UNIQUE INDEX UNIQ_3AF03EC5A832C1C9 (email_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'), // DBAL 4 (see https://github.com/doctrine/dbal/pull/4777) - self::equalTo('CREATE TABLE cms_users (id INT AUTO_INCREMENT NOT NULL, status VARCHAR(50) DEFAULT NULL, username VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, email_id INT DEFAULT NULL, UNIQUE INDEX UNIQ_3AF03EC5F85E0677 (username), UNIQUE INDEX UNIQ_3AF03EC5A832C1C9 (email_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'), + self::equalTo('CREATE TABLE cms_users (id INT AUTO_INCREMENT NOT NULL, reference VARBINARY(50) DEFAULT NULL, status VARCHAR(50) DEFAULT NULL, username VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, email_id INT DEFAULT NULL, UNIQUE INDEX UNIQ_3AF03EC5F85E0677 (username), UNIQUE INDEX UNIQ_3AF03EC5A832C1C9 (email_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'), )); self::assertEquals('CREATE TABLE cms_users_groups (user_id INT NOT NULL, group_id INT NOT NULL, INDEX IDX_7EA9409AA76ED395 (user_id), INDEX IDX_7EA9409AFE54D947 (group_id), PRIMARY KEY(user_id, group_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB', $sql[2]); self::assertEquals('CREATE TABLE cms_users_tags (user_id INT NOT NULL, tag_id INT NOT NULL, INDEX IDX_93F5A1ADA76ED395 (user_id), INDEX IDX_93F5A1ADBAD26311 (tag_id), PRIMARY KEY(user_id, tag_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB', $sql[3]); From 39566d549fabdcf66bc70b3e2159d4aea35580aa Mon Sep 17 00:00:00 2001 From: yevheniipererva Date: Wed, 11 Dec 2024 18:45:21 +0200 Subject: [PATCH 12/14] removed useless throws from description --- src/Persisters/Entity/BasicEntityPersister.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Persisters/Entity/BasicEntityPersister.php b/src/Persisters/Entity/BasicEntityPersister.php index 45dae839498..35015f27cc5 100644 --- a/src/Persisters/Entity/BasicEntityPersister.php +++ b/src/Persisters/Entity/BasicEntityPersister.php @@ -1932,9 +1932,6 @@ private function getTypes(string $field, mixed $value, ClassMetadata $class): ar /** * @psalm-return ArrayParameterType::* - * - * @throws QueryException - * @throws Exception */ private function getArrayBindingType(ParameterType|int|string $type): ArrayParameterType|int { From df43dcb48ecb2bc3afafadc144ab4c3f8679dbd6 Mon Sep 17 00:00:00 2001 From: yevheniipererva Date: Wed, 11 Dec 2024 18:45:47 +0200 Subject: [PATCH 13/14] cs fixed --- src/Persisters/Entity/BasicEntityPersister.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Persisters/Entity/BasicEntityPersister.php b/src/Persisters/Entity/BasicEntityPersister.php index 35015f27cc5..c43586fe9e9 100644 --- a/src/Persisters/Entity/BasicEntityPersister.php +++ b/src/Persisters/Entity/BasicEntityPersister.php @@ -1930,9 +1930,7 @@ private function getTypes(string $field, mixed $value, ClassMetadata $class): ar return $types; } - /** - * @psalm-return ArrayParameterType::* - */ + /** @phpstan-return ArrayParameterType::* */ private function getArrayBindingType(ParameterType|int|string $type): ArrayParameterType|int { if (! $type instanceof ParameterType) { From 3c40b39ce20f0bd9825387e87521bc405984b2cb Mon Sep 17 00:00:00 2001 From: yevheniipererva Date: Wed, 11 Dec 2024 18:46:20 +0200 Subject: [PATCH 14/14] cs fixed --- src/Persisters/Entity/BasicEntityPersister.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Persisters/Entity/BasicEntityPersister.php b/src/Persisters/Entity/BasicEntityPersister.php index c43586fe9e9..b722db04642 100644 --- a/src/Persisters/Entity/BasicEntityPersister.php +++ b/src/Persisters/Entity/BasicEntityPersister.php @@ -10,7 +10,6 @@ use Doctrine\Common\Collections\Order; use Doctrine\DBAL\ArrayParameterType; use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Exception; use Doctrine\DBAL\LockMode; use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Platforms\AbstractPlatform; @@ -1930,7 +1929,10 @@ private function getTypes(string $field, mixed $value, ClassMetadata $class): ar return $types; } - /** @phpstan-return ArrayParameterType::* */ + /** + * @psalm-return ArrayParameterType::* + * @throw QueryException˚ + */ private function getArrayBindingType(ParameterType|int|string $type): ArrayParameterType|int { if (! $type instanceof ParameterType) {