yiisoft / yii

Yii PHP Framework 1.1.x
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
4.84k stars 2.28k forks source link

CActiveRecord::findByPk Does Not Handle Binary Keys Correctly #3517

Closed BourgeoisBear closed 7 years ago

BourgeoisBear commented 10 years ago

If you have a mysql table with a primary key on a column of type BINARY(16) (for a UUID in my case), insert value of 0x92044ce93698443d88a947967462dd61 as one of the keys, then try to look it up using model()->findByPk(hex2bin('92044ce93698443d88a947967462dd61')), it will not find the record. From studying the underlying call to createPkCriteria() on line 1485, it seems as though there is an escaping issue with the aforementioned UUID in the query criteria. I do not know if this is a problem with Yii or PDO, but it should probably be addressed in the framework either way.

samdark commented 7 years ago

Won't be fixed in 1.1.