Skip to content
Permalink
Browse files

Don't hydrate empty association entities.

When hasOne/belongsTo (joinable associations) are empty we should skip
populating empty entities as they cause problems later on in the
request.

Refs #3806
Refs #3902
  • Loading branch information...
markstory committed Jul 9, 2014
1 parent da2af6d commit 34109118c7a43a221b099e0527588ea3d265b694
Showing with 8 additions and 1 deletion.
  1. +8 −1 src/ORM/ResultSet.php
@@ -400,14 +400,21 @@ protected function _groupResult($row) {
if ($assoc['canBeJoined']) {
$results[$alias] = $this->_castValues($target, $results[$alias]);
$hasData = array_filter($results[$alias], function ($v) {
return $v !== null;
});
if (!$hasData) {
continue;
}
}
if ($this->_hydrate && $assoc['canBeJoined']) {
$entity = new $assoc['entityClass']($results[$alias], $options);
$entity->clean();
$results[$alias] = $entity;
}
$results = $instance->transformRow($results, $alias, $assoc['canBeJoined']);
}

0 comments on commit 3410911

Please sign in to comment.
You can’t perform that action at this time.