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() {




		return array(


			'condition' => ' LIKE :search',

			'params' => array(':search' => '%Event%')





and then adding to the site/index view :






	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

Good catch. I just checked in the fix. Please help test it. Thanks!

hi qiang

thanks for the fixes !!

everything seems ok for named scopes

but the defaultScope thing now returns an error :

CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column '' in 'on clause'

the query :

SELECT AS t0_c0, AS t1_c0, AS t1_c1, AS t1_c2 FROM Artist LEFT OUTER JOIN ArtistEvent events_t1 ON ( LEFT OUTER JOIN Event t1 ON ( AND ( LIKE :search) WHERE ( IN (1, 2))

missing attributes in select to satifsfy the on clause ?

It's because of table alias.


my bad

good luck for the 1.0.5

really great release I feel