If the query condition field is binary and not the primary key, error will be reported under some binary cases. #251
Description
What steps will reproduce the problem?
https://github.com/vistart/yii2-redis/blob/master/tests/data/ar/CustomerBinary.php
https://github.com/vistart/yii2-redis/blob/master/tests/data/ar/CustomerBinaryQuery.php
I modify the Customer class and added a guid field without modifying the primary key.
Then in ActiveRecordTest, save an instance of the CustomeryBinary
and assign the guid to the binary form of "51a4e62e-1b1a-56c9-e9e5-9efe21f55276".
When testing the find()
based on the guid
value, it was found that the value was escaped in the buildHashCondition()
method. The escaped result is inconsistent with the saved result.
The test results are as follows:
https://github.com/vistart/yii2-redis/runs/7493880767
All modifications are as follows:
master...vistart:yii2-redis:master
If the primary key is a binary value, this error will not be occurred because the finding process does not go through the escaping. But if the primary key is a composite fields, which contains a binary field, this error will still be triggered.
What's expected?
Can use non-primary key binary values as query conditions.
What do you get instead?
If it is a binary value, it should not be escaped.
Additional info
Q | A |
---|---|
Yii vesion | 2.0.0 or later |
yii2-redis version | 2.0.0 or later |
PHP version | 5.4 ~ 8.1 |
Operating system | All |