#1277 DDC-3346 DDC-3531 - skipping joining of associations when limiting and fetch-joining to-many eager associations
This commit is contained in:
parent
67f60f2286
commit
a37fa97be3
@ -204,11 +204,13 @@ class BasicEntityPersister implements EntityPersister
|
||||
$this->identifierFlattener = new IdentifierFlattener($em->getUnitOfWork(), $em->getMetadataFactory());
|
||||
$this->cachedPersisterContexts['noLimits'] = $this->currentPersisterContext = new CachedPersisterContext(
|
||||
$class,
|
||||
new Query\ResultSetMapping()
|
||||
new Query\ResultSetMapping(),
|
||||
false
|
||||
);
|
||||
$this->cachedPersisterContexts['withLimits'] = new CachedPersisterContext(
|
||||
$class,
|
||||
new Query\ResultSetMapping()
|
||||
new Query\ResultSetMapping(),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
@ -1169,11 +1171,9 @@ class BasicEntityPersister implements EntityPersister
|
||||
* the resulting SQL fragment is generated only once and cached in {@link selectColumnListSql}.
|
||||
* Subclasses may or may not do the same.
|
||||
*
|
||||
* @param bool $hasLimitClause
|
||||
*
|
||||
* @return string The SQL fragment.
|
||||
*/
|
||||
protected function getSelectColumnsSQL(/*$hasLimitClause = false*/)
|
||||
protected function getSelectColumnsSQL()
|
||||
{
|
||||
//if ( ! $hasLimitClause && $this->selectColumnListSql !== null) {
|
||||
if ($this->currentPersisterContext->selectColumnListSql !== null) {
|
||||
@ -1206,6 +1206,10 @@ class BasicEntityPersister implements EntityPersister
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((($assoc['type'] & ClassMetadata::TO_MANY) > 0) && $this->currentPersisterContext->handlesLimits) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$eagerEntity = $this->em->getClassMetadata($assoc['targetEntity']);
|
||||
|
||||
if ($eagerEntity->inheritanceType != ClassMetadata::INHERITANCE_TYPE_NONE) {
|
||||
@ -1955,6 +1959,8 @@ class BasicEntityPersister implements EntityPersister
|
||||
{
|
||||
if (null === $offset && null === $limit) {
|
||||
$this->currentPersisterContext = $this->cachedPersisterContexts['noLimits'];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->currentPersisterContext = $this->cachedPersisterContexts['withLimits'];
|
||||
|
@ -78,15 +78,25 @@ class CachedPersisterContext
|
||||
*/
|
||||
public $sqlTableAliases = array();
|
||||
|
||||
/**
|
||||
* Whether this persistent context is considering limit operations applied to the selection queries
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $handlesLimits;
|
||||
|
||||
/**
|
||||
* @param ClassMetadata $class
|
||||
* @param ResultSetMapping $rsm
|
||||
* @param bool $handlesLimits
|
||||
*/
|
||||
public function __construct(
|
||||
ClassMetadata $class,
|
||||
ResultSetMapping $rsm
|
||||
ResultSetMapping $rsm,
|
||||
$handlesLimits
|
||||
) {
|
||||
$this->class = $class;
|
||||
$this->rsm = $rsm;
|
||||
$this->class = $class;
|
||||
$this->rsm = $rsm;
|
||||
$this->handlesLimits = (bool) $handlesLimits;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user