Commit 7a418ae9 by Klimov Paul

`yii\mongodb\Collection::buildLikeCondition()` fixed to be case insensitive.

parent 7aed617c
......@@ -1040,7 +1040,7 @@ class Collection extends Object
}
list($column, $value) = $operands;
if (!($value instanceof \MongoRegex)) {
$value = new \MongoRegex('/' . preg_quote($value) . '/');
$value = new \MongoRegex('/' . preg_quote($value) . '/i');
}
return [$column => $value];
......
......@@ -195,6 +195,7 @@ class QueryRunTest extends MongoDbTestCase
public function testLike()
{
$connection = $this->getConnection();
$query = new Query;
$rows = $query->from('customer')
->where(['LIKE', 'name', 'me1'])
......@@ -202,5 +203,11 @@ class QueryRunTest extends MongoDbTestCase
$this->assertEquals(2, count($rows));
$this->assertEquals('name1', $rows[0]['name']);
$this->assertEquals('name10', $rows[1]['name']);
$query = new Query;
$rowsUppercase = $query->from('customer')
->where(['LIKE', 'name', 'ME1'])
->all($connection);
$this->assertEquals($rows, $rowsUppercase);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment