Defaultscope Applied Twice?

I have two models:


class Tag extends CActiveRecord {

    //// ......


    public function defaultScope(){ 

        return array(

            'condition' => 'class_name = :class_name',

            'params' => array(':class_name' => get_class($this))

       );

    }


    public function relations(){

        return array(

            'videos' => array(self::MANY_MANY, 'Video', 'tags_videos(tag_id, video_id)')

        );

    }


    //// ......

}


class Video extends CActiveRecord {

    //// .......


    public function relations(){

        return array(

            'tags' => array(self::MANY_MANY, 'Tag', 'tags_videos(video_id, tag_id)')

        );

    }


    //// .......

}

When I try to get tags from video ($video_instance->tags) I get the following error:




 exception 'CDbException' with message 'CDbCommand failed to execute the SQL statement: SQLSTATE[HY093]: Invalid parameter number. The SQL statement executed was: SELECT `tags`.`id` AS `t1_c0`, `tags`.`name` AS `t1_c1`, `tags`.`orig_name` AS `t1_c2`, `tags`.`slug` AS `t1_c3`, `tags`.`flags` AS `t1_c4`, `tags`.`class_name` AS `t1_c5`, `tags`.`created_at` AS `t1_c6` FROM `tags` `tags`  INNER JOIN `tags_videos` `tags_tags` ON (`tags_tags`.`video_id`=:ypl0) AND (`tags`.`id`=`tags_tags`.`tag_id`) AND (class_name = :class_name) WHERE (class_name = :class_name)' in /srv/http/yii-1.1.12.b600af/framework/db/CDbCommand.php:528



My question is: why my default scope is applied twice to query (in WHERE and in ON) and how do I fix this?

I understand I can throw away params and just add class name to condition, but imho it is wrong and thats a workaround, not a solution.

Yii version: 1.1.12.b600af

PHP: 5.4.8

Create issue on tracker: https://github.com/yiisoft/yii/issues/1597