relation with 'on' condition using fields from the base table.


I have a relation like this:

    public function relations()


        $t = $this->getTableAlias(true,true).".";

        // NOTE: you may need to adjust the relation name and the related

        // class name for the relations automatically generated below.

        return array(

                'entity' => array(self::BELONGS_TO, 'Entity', 'entity_id'),

                'credits' => array(self::HAS_MANY, 'SubscriptionCredit', 'entity_id',

                        'on'=>"(`credits`.`start_date` BETWEEN $t`start_date` AND $t`end_date`)

                        OR (`credits`.`end_date` BETWEEN $t`start_date` AND $t`end_date`)

                        OR ($t`start_date` BETWEEN `credits`.`start_date` AND `credits`.`end_date`)"),



The ‘on’ condition uses ‘columns’ from the base table which works find when the relation is fetched eagerly like this (“with” does the trick):



This does not work:



because ‘t.start_date’ is not found.

Any suggestion avoiding the use of ‘with’ with ‘findAll’ ?