Skip to content

Commit c68b8f9

Browse files
committed
adds a test for postgres that uses a HIDDEN result variable for ordering based on arithmetic expression
1 parent aa4f9ce commit c68b8f9

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

tests/Doctrine/Tests/ORM/Functional/GH8011Test.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
88
use Doctrine\Tests\Models\Company\CompanyEmployee;
99
use Doctrine\Tests\OrmFunctionalTestCase;
10-
1110
use function count;
1211

1312
/**
@@ -204,6 +203,20 @@ public function testOrderWithArithmeticExpressionWithSingleValuedPathExpressionA
204203
$this->assertEquals('Benjamin E.', $result[1]->getName());
205204
}
206205

206+
public function testOrderWithArithmeticExpressionWithLiteralAndResultVariableUsingHiddenResultVariable(): void
207+
{
208+
$dql = 'SELECT p, p.salary AS HIDDEN s, 1 + s AS HIDDEN _order ' .
209+
'FROM Doctrine\Tests\Models\Company\CompanyEmployee p ' .
210+
'ORDER BY _order DESC';
211+
212+
/** @var CompanyEmployee[] $result */
213+
$result = $this->_em->createQuery($dql)->getResult();
214+
215+
$this->assertEquals(2, count($result));
216+
$this->assertEquals('Guilherme B.', $result[0]->getName());
217+
$this->assertEquals('Benjamin E.', $result[1]->getName());
218+
}
219+
207220
public function generateFixture(): void
208221
{
209222
$person1 = new CompanyEmployee();

0 commit comments

Comments
 (0)