Skip to content

Commit

Permalink
Optimized column fetching in loadInto()
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Jun 28, 2015
1 parent ed67eaf commit 04c811b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/ORM/LazyEagerLoader.php
Expand Up @@ -49,8 +49,9 @@ protected function _getQuery($objects, $contain, $source)
return $entity->{$method}($primaryKey);
});

return $source
$query = $source
->find()
->select((array)$primaryKey)
->where(function ($exp) use ($primaryKey, $keys, $source) {
if (is_array($primaryKey) && count($primaryKey) === 1) {
$primaryKey = current($primaryKey);
Expand All @@ -64,6 +65,14 @@ protected function _getQuery($objects, $contain, $source)
return new TupleComparison($primaryKey, $keys->toList());
})
->contain($contain);

foreach ($query->eagerLoader()->attachableAssociations($source) as $loadable) {
$config = $loadable->config();
$config['includeFields'] = true;
$loadable->config($config);
}

return $query;
}

protected function _getPropertyMap($source, $associations)
Expand Down

0 comments on commit 04c811b

Please sign in to comment.