DDC-644 - Fixed issue with undefined columns in ResultSetMapping by skipping them, added a functional test for modified limit query functionality
This commit is contained in:
parent
86e24d373b
commit
553e93ae27
@ -184,6 +184,10 @@ abstract class AbstractHydrator
|
|||||||
$cache[$key]['type'] = Type::getType($classMetadata->fieldMappings[$fieldName]['type']);
|
$cache[$key]['type'] = Type::getType($classMetadata->fieldMappings[$fieldName]['type']);
|
||||||
$cache[$key]['isIdentifier'] = $classMetadata->isIdentifier($fieldName);
|
$cache[$key]['isIdentifier'] = $classMetadata->isIdentifier($fieldName);
|
||||||
$cache[$key]['dqlAlias'] = $this->_rsm->columnOwnerMap[$key];
|
$cache[$key]['dqlAlias'] = $this->_rsm->columnOwnerMap[$key];
|
||||||
|
} else if (!isset($this->_rsm->metaMappings[$key])) {
|
||||||
|
// this column is a left over, maybe from a LIMIT query hack for example in Oracle or DB2
|
||||||
|
// maybe from an additional column that has not been defined in a NativeQuery ResultSetMapping.
|
||||||
|
continue;
|
||||||
} else {
|
} else {
|
||||||
// Meta column (has meaning in relational schema only, i.e. foreign keys or discriminator columns).
|
// Meta column (has meaning in relational schema only, i.e. foreign keys or discriminator columns).
|
||||||
$cache[$key]['isMetaColumn'] = true;
|
$cache[$key]['isMetaColumn'] = true;
|
||||||
|
@ -267,6 +267,38 @@ class QueryTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
|||||||
->getSingleScalarResult();
|
->getSingleScalarResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testModifiedLimitQuery()
|
||||||
|
{
|
||||||
|
for ($i = 0; $i < 5; $i++) {
|
||||||
|
$user = new CmsUser;
|
||||||
|
$user->name = 'Guilherme' . $i;
|
||||||
|
$user->username = 'gblanco' . $i;
|
||||||
|
$user->status = 'developer';
|
||||||
|
$this->_em->persist($user);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->_em->flush();
|
||||||
|
$this->_em->clear();
|
||||||
|
|
||||||
|
$data = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u')
|
||||||
|
->setFirstResult(1)
|
||||||
|
->setMaxResults(2)
|
||||||
|
->getResult();
|
||||||
|
|
||||||
|
$this->assertEquals(2, count($data));
|
||||||
|
$this->assertEquals('gblanco1', $data[0]->username);
|
||||||
|
$this->assertEquals('gblanco2', $data[1]->username);
|
||||||
|
|
||||||
|
$data = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u')
|
||||||
|
->setFirstResult(3)
|
||||||
|
->setMaxResults(2)
|
||||||
|
->getResult();
|
||||||
|
|
||||||
|
$this->assertEquals(2, count($data));
|
||||||
|
$this->assertEquals('gblanco3', $data[0]->username);
|
||||||
|
$this->assertEquals('gblanco4', $data[1]->username);
|
||||||
|
}
|
||||||
|
|
||||||
public function testSupportsQueriesWithEntityNamespaces()
|
public function testSupportsQueriesWithEntityNamespaces()
|
||||||
{
|
{
|
||||||
$this->_em->getConfiguration()->addEntityNamespace('CMS', 'Doctrine\Tests\Models\CMS');
|
$this->_em->getConfiguration()->addEntityNamespace('CMS', 'Doctrine\Tests\Models\CMS');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user