You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
romosan
changed the title
Eager-loaded has_many relations are not cached when null
Eager-loaded relations are not cached when null
Apr 20, 2023
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 probablymany_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: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.
The text was updated successfully, but these errors were encountered: