Commit dc3ada65 by Klimov Paul

Mongo query "IN" condition shortcut syntax added.

parent a0384498
......@@ -242,7 +242,13 @@ class Collection extends Object
if (is_numeric($key)) {
$result[] = $actualValue;
} else {
$result[$this->normalizeConditionKeyword($key)] = $actualValue;
$key = $this->normalizeConditionKeyword($key);
if (strncmp('$', $key, 1) !== 0 && array_key_exists(0, $actualValue)) {
// shortcut for IN condition
$result[$key]['$in'] = $actualValue;
} else {
$result[$key] = $actualValue;
}
}
}
return $result;
......
......@@ -75,9 +75,7 @@ class QueryRunTest extends MongoTestCase
$query = new Query;
$rows = $query->from('customer')
->where([
'name' => [
'in' => ['name1', 'name5']
]
'name' => ['name1', 'name5']
])
->all($connection);
$this->assertEquals(2, count($rows));
......
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