So, after more tests, I did find an issue in the ORM relation on 1.9/dev. Not the one OP first mentioned, through.
The empty relations, that would normally exists in _data_relations and _original_relations (with null value for belongs_to and has_one, and empty array for has_many and many_many) aren't defined.
Not breaking anything, but any call to those relations will cause an additional SQL query to try to lazyload the relation per relation and model instance.
you run a query with a related model, but there are no related records. In this case the empty relation is not created, so access assumes there was no relared model, and it will fire a lazy load query (which obviously doesn't return anything?
Exactly. I looked up the code, and this behavior seems to be caused by : query.php -> process_row() -> l.1527 (And the same behavior for multiple pks just below)
// construct the PK string representation for this record
if (count($model['pk']) == 1)
{
$pk = $record[$model['pk'][0]];
// skip empty results
if (is_null($pk))
{
continue;
}
}
A related model without record has its PK set to null, and hence not being handled further. Wanna me to PR a fix ?
My home server has crashed with a mainboard failure earlier today, so I can't do much until the replacement has arrived and it is up and running again...