custom fk->pk fails if parent AR is "new"

When using the new (in Yii 1.1.9?) feature of specifying a key column that is not the primary key as the target for a foreign key in a 1-1 or 1-many relation, no records are returned by a lazy load if the record declaring the relation is "new", even if there are existing foreign records in the DB that reference the new record. Examination of the code at line 254 (version 1.1.10) of CActiveRecord discloses an explicit check for newness and the return of NULL or an empty array. This appears to merely be an optimization and removal of this if statement seems to make things work properly. However, I am not sure that subtle bad side effects are not introduced.

An example of the type of relation where this problem is exhibited:

public function relations() {

return array( 

		'foreigners'=>array(CActiveRecord::HAS_MANY, 'Foreign', array('foreignkey'=>'localkey'))



Now you might say, why would you do this? It makes sense if the key field is a type field that relates records representing a particular type of activity with a newly created activity occurrence record. In this case, the code creating the new activity occurrence record sets the type field and then wants to perform further processing after retrieving the type records from the DB via lazy load prior to saving the new record to the DB.