Merge pull request #1377 from fprochazka/bugfix/paginator
LimitSubqueryOutputWalker: fix aliasing of property in OrderBy from MappedSuperclass
This commit is contained in:
commit
3f84be7b7c
@ -438,7 +438,9 @@ class LimitSubqueryOutputWalker extends SqlWalker
|
|||||||
// Field was declared in a parent class, so we need to get the proper SQL table alias
|
// Field was declared in a parent class, so we need to get the proper SQL table alias
|
||||||
// for the joined parent table.
|
// for the joined parent table.
|
||||||
$otherClassMetadata = $this->em->getClassMetadata($fieldMapping['declared']);
|
$otherClassMetadata = $this->em->getClassMetadata($fieldMapping['declared']);
|
||||||
$sqlTableAliasForFieldAlias = $this->getSQLTableAlias($otherClassMetadata->getTableName(), $dqlAliasForFieldAlias);
|
if (!$otherClassMetadata->isMappedSuperclass) {
|
||||||
|
$sqlTableAliasForFieldAlias = $this->getSQLTableAlias($otherClassMetadata->getTableName(), $dqlAliasForFieldAlias);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compose search/replace patterns
|
// Compose search/replace patterns
|
||||||
|
@ -350,5 +350,24 @@ ORDER BY b.id DESC'
|
|||||||
$query->getSQL()
|
$query->getSQL()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This tests ordering by property that has the 'declared' field.
|
||||||
|
*/
|
||||||
|
public function testLimitSubqueryOrderByFieldFromMappedSuperclass()
|
||||||
|
{
|
||||||
|
$this->entityManager->getConnection()->setDatabasePlatform(new MySqlPlatform());
|
||||||
|
|
||||||
|
// now use the third one in query
|
||||||
|
$query = $this->entityManager->createQuery(
|
||||||
|
'SELECT b FROM Doctrine\Tests\ORM\Tools\Pagination\Banner b ORDER BY b.id DESC'
|
||||||
|
);
|
||||||
|
$query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Tools\Pagination\LimitSubqueryOutputWalker');
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
'SELECT DISTINCT id_0 FROM (SELECT b0_.id AS id_0, b0_.name AS name_1 FROM Banner b0_) dctrn_result ORDER BY id_0 DESC',
|
||||||
|
$query->getSQL()
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,4 +168,23 @@ class Avatar
|
|||||||
public $image_width;
|
public $image_width;
|
||||||
/** @Column(type="string", length=255) */
|
/** @Column(type="string", length=255) */
|
||||||
public $image_alt_desc;
|
public $image_alt_desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @MappedSuperclass */
|
||||||
|
abstract class Identified
|
||||||
|
{
|
||||||
|
/** @Id @Column(type="integer") @GeneratedValue */
|
||||||
|
private $id;
|
||||||
|
|
||||||
|
public function getId()
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @Entity */
|
||||||
|
class Banner extends Identified
|
||||||
|
{
|
||||||
|
/** @Column(type="string") */
|
||||||
|
public $name;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user