Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query hydrate: update_original_relation only for relations concerned #312

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion classes/query.php
Original file line number Diff line number Diff line change
Expand Up @@ -1115,13 +1115,15 @@ public function hydrate(&$row, $models, &$result, $model = null, $select = null,

// start fetching relationships
$rel_objs = $obj->_relate();
$relations_updated = array();
foreach ($models as $m)
{
// when the expected model is empty, there's nothing to be done
if (empty($m['model']))
{
continue;
}
$relations_updated[] = $m['rel_name'];

// when not yet set, create the relation result var with null or array
if ( ! array_key_exists($m['rel_name'], $rel_objs))
Expand All @@ -1142,7 +1144,7 @@ public function hydrate(&$row, $models, &$result, $model = null, $select = null,

// attach the retrieved relations to the object and update its original DB values
$obj->_relate($rel_objs);
$obj->_update_original_relations();
$obj->_update_original_relations($relations_updated);

return $obj;
}
Expand Down