Duplicate bind values when combining scope and criteria parameter with in conditons

The following query throws an error:

$recordCount = $model->filtered()->count($criteria);

The filtered scope adds (among other things):

$criteria->addInCondition(’“Entity”."’ . $entityId123 . ‘"’, $filters[‘read’][$entityId123]);

The $criteria adds (among other things):

$criteria->addInCondition(’"’ . $model->modelName . ‘".“id”’, $ids);

The resulting query appears to use the same bind parameters for both:

SELECT COUNT(*) FROM "Payment" INNER JOIN "Entity" ON "Entity"."id"="entityId" WHERE (("Payment"."organizationId" = :organizationId) AND ("Entity"."entityId1" IN (:ycp0, :ycp1))) AND ("Payment"."id" IN (:ycp0, :ycp1))

Full trace:

2010/03/18 16:01:03 [error] [system.db.CDbCommand] Error in querying SQL: SELECT COUNT(*) FROM "Payment" INNER JOIN "Entity" ON "Entity"."id"="entityId" WHERE (("Payment"."organizationId" = :organizationId) AND ("Entity"."entityId1" IN (:ycp0, :ycp1))) AND ("Payment"."id" IN (:ycp0, :ycp1))

2010/03/18 16:01:03 [error] [exception.CDbException] exception ‘CDbException’ with message 'CDbCommand failed to execute the SQL statement: SQLSTATE[42883]: Undefined function: 7 ERROR: operator does not exist: character varying = integer at character 146

HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.’ in /home/palmer/yii_11/framework/db/CDbCommand.php:375

Stack trace:

#0 /home/palmer/yii_11/framework/db/CDbCommand.php(302): CDbCommand->queryInternal(‘fetchColumn’, 0, Array)

#1 /home/palmer/yii_11/framework/db/ar/CActiveRecord.php(1300): CDbCommand->queryScalar()

#2 /home/palmer/www/tcs.palmerhill.com/protected/actions/ListXmlAction.php(77): CActiveRecord->count(Object(CDbCriteria))

#3 /home/palmer/yii_11/framework/web/CController.php(300): ListXmlAction->run()

#4 /home/palmer/yii_11/framework/web/filters/CFilterChain.php(129): CController->runAction(Object(ListXmlAction))

#5 /home/palmer/yii_11/framework/web/filters/CFilter.php(41): CFilterChain->run()

#6 /home/palmer/yii_11/framework/web/CController.php(957): CFilter->filter(Object(CFilterChain))

#7 /home/palmer/yii_11/framework/web/filters/CInlineFilter.php(59): CController->filterAccessControl(Object(CFilterChain))

#8 /home/palmer/yii_11/framework/web/filters/CFilterChain.php(126): CInlineFilter->filter(Object(CFilterChain))

#9 /home/palmer/yii_11/framework/web/CController.php(283): CFilterChain->run()

#10 /home/palmer/yii_11/framework/web/CController.php(257): CController->runActionWithFilters(Object(ListXmlAction), Array)

#11 /home/palmer/yii_11/framework/web/CWebApplication.php(320): CController->run(‘listXml’)

#12 /home/palmer/yii_11/framework/web/CWebApplication.php(120): CWebApplication->runController(‘payment/listXml…’)

#13 /home/palmer/yii_11/framework/base/CApplication.php(135): CWebApplication->processRequest()

#14 /home/palmer/www/tcs.palmerhill.com/index.php(11): CApplication->run()

#15 {main} REQUEST_URI=/payment/listXml/ids[0]/298/ids[1]/299

I suggest you to create new ticket for this