1
0
mirror of synced 2025-03-27 10:23:50 +03:00

Added failing test cases for limit queries with with complex scalar order by items

This commit is contained in:
Bill Schaller 2014-12-16 11:59:13 -05:00 committed by Marco Pivetta
parent a4ebc08c4f
commit 42bea80a6a
2 changed files with 49 additions and 0 deletions

View File

@ -5,6 +5,7 @@ namespace Doctrine\Tests\ORM\Tools\Pagination;
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Platforms\OraclePlatform;
use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
use Doctrine\DBAL\Platforms\SQLServerPlatform;
use Doctrine\ORM\Query;
class LimitSubqueryOutputWalkerTest extends PaginationTestCase
@ -212,6 +213,36 @@ class LimitSubqueryOutputWalkerTest extends PaginationTestCase
);
}
public function testCountQueryWithComplexScalarOrderByItem()
{
$query = $this->entityManager->createQuery(
'SELECT a FROM Doctrine\Tests\ORM\Tools\Pagination\Avatar a ORDER BY a.image_height * a.image_width DESC'
);
$this->entityManager->getConnection()->setDatabasePlatform(new MySqlPlatform());
$query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Tools\Pagination\LimitSubqueryOutputWalker');
$this->assertSame(
'SELECT DISTINCT id_0, image_height_2, image_width_3 FROM (SELECT a0_.id AS id_0, a0_.image AS image_1, a0_.image_height AS image_height_2, a0_.image_width AS image_width_3, a0_.user_id AS user_id_4 FROM Avatar a0_) dctrn_result ORDER BY image_height_2 * image_width_3 DESC',
$query->getSQL()
);
}
public function testCountQueryWithComplexScalarOrderByItemOracle()
{
$query = $this->entityManager->createQuery(
'SELECT a FROM Doctrine\Tests\ORM\Tools\Pagination\Avatar a ORDER BY a.image_height * a.image_width DESC'
);
$this->entityManager->getConnection()->setDatabasePlatform(new OraclePlatform());
$query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Tools\Pagination\LimitSubqueryOutputWalker');
$this->assertSame(
'SELECT DISTINCT ID_0, IMAGE_HEIGHT_2, IMAGE_WIDTH_3 FROM (SELECT a0_.id AS ID_0, a0_.image AS IMAGE_1, a0_.image_height AS IMAGE_HEIGHT_2, a0_.image_width AS IMAGE_WIDTH_3, a0_.user_id AS USER_ID_4 FROM Avatar a0_) dctrn_result ORDER BY IMAGE_HEIGHT_2 * IMAGE_WIDTH_3 DESC',
$query->getSQL()
);
}
/**
* @group DDC-3434
*/

View File

@ -145,3 +145,21 @@ class User
*/
public $groups;
}
/** @Entity */
class Avatar
{
/** @Id @column(type="integer") @generatedValue */
public $id;
/**
* @OneToOne(targetEntity="User", inversedBy="avatar")
* @JoinColumn(name="user_id", referencedColumnName="id")
*/
public $user;
/** @column(type="string", length=255) */
public $image;
/** @column(type="integer") */
public $image_height;
/** @column(type="integer") */
public $image_width;
}