-
Notifications
You must be signed in to change notification settings - Fork 96
Description
I hope this is a bug and not a feature, because the latest version of the ORM doesn't cache the result of eager-loading has_many relations (and probably many_many as well) when there are no related records found. This happens at least since the commit 776c245 (speedup of the hydration process) and it causes the relation to be lazy-loaded redundantly when it is accessed for the second time. In 1.8.2, an empty array was set from the first load and it prevented the second one from happening.
In the current \Orm\Query::process_row function, this code seems to me to be the problem:
// skip the rest if we don't have a pk (= no result)
if (is_null($pk))
{
continue;
}Perhaps before this continue, an empty array should be added to $pointers if ($model['singular'] === false).
Edit: A null value doesn't seem to be set in the case of singular relations which haven't been found either.