CActiveDataProvider and CGridView relation field and condition join BUG

Hi.

It seems to be a bug in 1.1.1

I have this:




$criteria=new CDbCriteria;

$criteria->with('someRelation');

$adp = new ActiveDataProvider('MyModel', array(

   'criteria'=>$criteria,

);


/* Widget code with $adp */



It’s ok, SQL runs with join, but when I add condition:




$criteria=new CDbCriteria;

$criteria->with('someRelation');

$criteria->condition = 'someRelation.fieldId = 1';

$adp = new ActiveDataProvider('MyModel', array(

   'criteria'=>$criteria,

);


/* Widget code with $adp */



there is no join statement in SQL.

The only way I found is to use


$criteria->join = 'LEFT JOIN someRelation on MyModel.someRelationId = someRelation.id';

Is that bug or I did not understand something? :)

If your relation is a MANY_MANY, I think it’s a bug. The same problem was reported in a previous post.

It seems to be related to bug 910, marked invalid even though the reporter did not agree.

It can be HAS_MANY too