diff --git a/extensions/mongo/Collection.php b/extensions/mongo/Collection.php index 7292348..5f7246c 100644 --- a/extensions/mongo/Collection.php +++ b/extensions/mongo/Collection.php @@ -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; diff --git a/tests/unit/extensions/mongo/QueryRunTest.php b/tests/unit/extensions/mongo/QueryRunTest.php index b36851a..f8821b6 100644 --- a/tests/unit/extensions/mongo/QueryRunTest.php +++ b/tests/unit/extensions/mongo/QueryRunTest.php @@ -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));