From 03206708221a260d300d82e74e10149e16640418 Mon Sep 17 00:00:00 2001
From: Dirk Adler <adler@spacedealer.de>
Date: Fri, 28 Mar 2014 11:12:38 +0100
Subject: [PATCH] Changes mongodb build and condition, fixes #2868

---
 extensions/mongodb/Collection.php |  9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/extensions/mongodb/Collection.php b/extensions/mongodb/Collection.php
index 237fb08..58294b3 100644
--- a/extensions/mongodb/Collection.php
+++ b/extensions/mongodb/Collection.php
@@ -772,6 +772,7 @@ class Collection extends Object
     protected function normalizeConditionKeyword($key)
     {
         static $map = [
+            'AND' => '$and',
             'OR' => '$or',
             'IN' => '$in',
             'NOT IN' => '$nin',
@@ -898,13 +899,13 @@ class Collection extends Object
      */
     public function buildAndCondition($operator, $operands)
     {
-        $result = [];
+        $operator = $this->normalizeConditionKeyword($operator);
+        $parts = [];
         foreach ($operands as $operand) {
-            $condition = $this->buildCondition($operand);
-            $result = array_merge_recursive($result, $condition);
+            $parts[] = $this->buildCondition($operand);
         }
 
-        return $result;
+        return [$operator => $parts];
     }
 
     /**
--
libgit2 0.27.1