if no records are returned for the 'filtered' related model, trying to access those (absent records) will trigger a lazy loading on the related model whereas it should not, since we want to be able to account for the fact that there are no records within the named scope.
you can check the application.log where I have stated which logs belongs to which revision
testing with rev 1004 :
- the Event active named scope ('condition' => 'Event.active = 1', 'alias' => 'Event') IS NOT taken into account (no additional condition in sql query)
- Can not check if a lazy load is performed when cheking for returned events (when no related models should be returned) because since the scope is not taken into account there are always events returned for an artist
testing with rev 956 :
- the Event active named scope ('condition' => 'Event.active = 1', 'alias' => 'Event') IS taken into account
- when NO events are returned for an artist calling count($artist->events) triggers a lazy load whereas counting active events for an artist which does not have any should return 0, instead it returns the number of all events for this artist regardless of the named scope (because of the lazy load)
Seems to affect only MANY_MANY relationships where 'condition' is not added to 'on' yet:
SELECT
`Artist`.`id` AS t0_c0, Event.`id` AS t1_c0, Event.`name` AS t1_c1, Event.`active` AS t1_c2
FROM `Artist`
LEFT OUTER JOIN `ArtistEvent` events_Event ON (`Artist`.`id`=events_Event.`Artist_id`)
LEFT OUTER JOIN `Event` Event ON (Event.`id`=events_Event.`Event_id`)
WHERE (`Artist`.`id` IN (1, 2))
Which should be:
SELECT
`Artist`.`id` AS t0_c0, Event.`id` AS t1_c0, Event.`name` AS t1_c1, Event.`active` AS t1_c2
FROM `Artist`
LEFT OUTER JOIN `ArtistEvent` events_Event ON (`Artist`.`id`=events_Event.`Artist_id`)
LEFT OUTER JOIN `Event` Event ON (Event.`id`=events_Event.`Event_id` AND Event.active=1)
WHERE (`Artist`.`id` IN (1, 2))