hi,
was wondering if new defaultScope() was supposed to be called for every query on the model
it does not seem to be the case at the moment (rev 1005)
calling a find operation directly on the model works
not with lazy loading nor 'with' in an eager call
this can be seen adding a defaultScope to the Event model in the test app I attached to the thread about named scopes
http://www.yiiframew…pic,2037.0.html :
public function defaultScope() { Yii::trace('DEFAULT SCOPE CALLED'); return array( 'condition' => 'Event.name LIKE :search', 'params' => array(':search' => '%Event%') ); }
and then adding to the site/index view :
<h3>ALL EVENTs DIRECTLY</h3> <p> </p> <?php Yii::trace('INACTIVE events for artists'); $events = Event::model()->findAll(); echo '<ul>'; foreach($events as $event) { echo '<li>' . $event->name . '</li>'; echo '<p>number of artists: ' . count($event->artists) . '</p>'; echo '<ul>'; foreach($event->artists as $artist) { echo '<li>' . $artist->name . '</li>'; } echo '</ul><br>'; } echo '</ul>'; ?>
rename an event in the db with something that does not contain Event.
the last test show only 3 events
the previous tests show all events regardless of the defaultScope
hope i'm not overlooking something obvious