Aftef CPagination::applyLimit() CDbCriteria lost relation

I have this ugly bug:

DB schema




$criteria = new CDbCriteria;

$criteria->with = array(

	'candidates',

	'candidates.jobRequest',

);

$criteria->addCondition('t.status=1');

$criteria->addCondition('jobRequest.userId=:uid');

$criteria->params = array(

	':uid' => Yii::app()->user->id,

);


$interviews = Interview::model()->findAll($criteria);



Until this point everything is working like a charm (selects all Interviews where JobRequest is belonging to particular User). But when I want to paginate, exception raises:




$pager = new CPagination(Interview::model()->count($criteria));

$pager->pageSize = 2;

$pager->applyLimit($criteria);


$interviews = Interview::model()->findAll($criteria);



Column not found: 1054 Unknown column ‘jobRequest.userId’

In generated SQL, there is no LEFT JOIN to Candidate and JobRequest present. Deeper investigation showed, that applying limit to CDbCriteria is causing this (losting LEFT JOIN from SQL). Does anybody have any idea?

to relation with jobRequest you should add


'together' => true

Have a look together from AR docmentations