this class is nearly completely duplicated from `yii\db\ActiveRelation` except the last few lines.