Commit ec195360 by Klimov Paul

Fixed `yii\mongodb\Collection::buildInCondition()` handles non-sequent key arrays

parent 7669689f
...@@ -6,6 +6,7 @@ Yii Framework 2 mongodb extension Change Log ...@@ -6,6 +6,7 @@ Yii Framework 2 mongodb extension Change Log
- Bug #2337: `yii\mongodb\Collection::buildLikeCondition()` fixed to escape regular expression (klimov-paul) - Bug #2337: `yii\mongodb\Collection::buildLikeCondition()` fixed to escape regular expression (klimov-paul)
- Bug #3385: Fixed "The 'connected' property is deprecated" (samdark) - Bug #3385: Fixed "The 'connected' property is deprecated" (samdark)
- Bug #4879: Fixed `yii\mongodb\Collection::buildInCondition()` handles non-sequent key arrays (klimov-paul)
- Enh #3520: Added `unlinkAll()`-method to active record to remove all records of a model relation (NmDimas, samdark, cebe) - Enh #3520: Added `unlinkAll()`-method to active record to remove all records of a model relation (NmDimas, samdark, cebe)
- Enh #3778: Gii generator for Active Record model added (klimov-paul) - Enh #3778: Gii generator for Active Record model added (klimov-paul)
- Enh #3947: Migration support added (klimov-paul) - Enh #3947: Migration support added (klimov-paul)
......
...@@ -998,7 +998,7 @@ class Collection extends Object ...@@ -998,7 +998,7 @@ class Collection extends Object
} else { } else {
$inValues = $values[$column]; $inValues = $values[$column];
} }
$result[$column][$operator] = $inValues; $result[$column][$operator] = array_values($inValues);
} }
return $result; return $result;
......
...@@ -210,4 +210,30 @@ class QueryRunTest extends MongoDbTestCase ...@@ -210,4 +210,30 @@ class QueryRunTest extends MongoDbTestCase
->all($connection); ->all($connection);
$this->assertEquals($rows, $rowsUppercase); $this->assertEquals($rows, $rowsUppercase);
} }
/**
* @see https://github.com/yiisoft/yii2/issues/4879
*
* @depends testInCondition
*/
public function testInConditionIgnoreKeys()
{
$connection = $this->getConnection();
$query = new Query;
$rows = $query->from('customer')
/*->where([
'name' => [
0 => 'name1',
15 => 'name5'
]
])*/
->where(['in', 'name', [
10 => 'name1',
15 => 'name5'
]])
->all($connection);
$this->assertEquals(2, count($rows));
$this->assertEquals('name1', $rows[0]['name']);
$this->assertEquals('name5', $rows[1]['name']);
}
} }
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