1.1.7 breaks merging of CDbCriterias

In our project we can’t upgrade to 1.1.7 because we can’t use a construct like this anymore (irrelevant code left out):




 class User extends CActiveRecord

{


    public function relations()

    {

        return array(

                'team'=>array(self::BELONGS_TO,'Team','id_team'),

        );

    }


    // Named parameterized scope: select only User if given team_id relates to active team

 	public function team($id)

    {

        $this->getDbCriteria()->mergeWith(array(

            'with'=>array(

                'team'=>array(

                    'select'=>array(),

                    'on'=>'team.active=1',

                    'joinType'=>'INNER JOIN',

                ),

            ),

        ));

        return $this;

    }

}



Irrelevant code removed, see below

You can’t reuse the obtained the CDbCriteria from a model, if complex scopes where applied to it:


$criteria=User::model->team(1)->getDbCriteria();

User::model()->findAll($criteria);

[font="Verdana"]

CException

[color="#000000"][size="2"]Property "CDbCriteria.on" is not defined.[/size][/color]

[/font]

http://code.google.com/p/yii/issues/detail?id=2274

The issue is even easier to reproduce: You can’t merge “with” conditions in a CDbCriteria anymore:

[font="arial, sans-serif"][size="2"]


class User extends CActiveRecords{

    public function relations()

    {

        return array(

            'team'=>array(self::BELONGS_TO,'Team','id_team'),

        );

    }    

    public function scopes()

    {

        return array(

            'activeteams'=>array(

   	         'with'=>array(

   		         'team'=>array(

   			         'condition'=>'team.active=1',

   		         ),

   	         ),

            ),

        );

    }

}


User::model()->activeteams()->findAll(array(

    'with'=>array(

        'team'=>array(

            'joinType'=>'INNER JOIN',

        ),

    ), 

));

[/size][/font]

Issue was fixed.

For the record: The issue only appeared when merging CDbCriterias that had ‘with’ properties with ‘on’ or ‘joinType’.