Bläddra i källkod

Fix type conversion in MongoCursor

Andreas Braun 10 år sedan
förälder
incheckning
68bb975599
3 ändrade filer med 17 tillägg och 3 borttagningar
  1. 12 0
      README.md
  2. 3 2
      lib/Mongo/MongoCursor.php
  3. 2 1
      tests/Alcaeus/MongoDbAdapter/MongoCursorTest.php

+ 12 - 0
README.md

@@ -68,6 +68,18 @@ root:
  method does not yet return the same result as the original method. Instead, it
  method does not yet return the same result as the original method. Instead, it
  always returns the name of the index created.
  always returns the name of the index created.
 
 
+## MongoCursor
+ - The [MongoCursor::explain](https://php.net/manual/de/mongocursor.explain.php)
+ method is not yet implemented.
+ - The [MongoCursor::hasNext](https://php.net/manual/de/mongocursor.hasnext.php)
+ method is not yet implemented.
+ - The [MongoCursor::setFlag](https://php.net/manual/de/mongocursor.setflag.php)
+ method is not yet implemented.
+
+## MongoCommandCursor
+ - The [MongoCommandCursor::createFromDocument](https://php.net/manual/de/mongocommandcursor.createfromdocument.php)
+ method is not yet implemented.
+
 ## Types
 ## Types
 
 
  - Return values containing objects of the [MongoDB\BSON\Javascript](https://secure.php.net/manual/de/class.mongodb-bson-javascript.php)
  - Return values containing objects of the [MongoDB\BSON\Javascript](https://secure.php.net/manual/de/class.mongodb-bson-javascript.php)

+ 3 - 2
lib/Mongo/MongoCursor.php

@@ -14,6 +14,7 @@
  */
  */
 
 
 use Alcaeus\MongoDbAdapter\AbstractCursor;
 use Alcaeus\MongoDbAdapter\AbstractCursor;
+use Alcaeus\MongoDbAdapter\TypeConverter;
 use MongoDB\Driver\Cursor;
 use MongoDB\Driver\Cursor;
 use MongoDB\Driver\ReadPreference;
 use MongoDB\Driver\ReadPreference;
 use MongoDB\Operation\Find;
 use MongoDB\Operation\Find;
@@ -140,7 +141,7 @@ class MongoCursor extends AbstractCursor implements Iterator
 
 
         $options = $this->getOptions($optionNames) + $this->options;
         $options = $this->getOptions($optionNames) + $this->options;
 
 
-        $count = $this->collection->count($this->query, $options);
+        $count = $this->collection->count(TypeConverter::fromLegacy($this->query), $options);
         return $count;
         return $count;
     }
     }
 
 
@@ -154,7 +155,7 @@ class MongoCursor extends AbstractCursor implements Iterator
     {
     {
         $options = $this->getOptions() + $this->options;
         $options = $this->getOptions() + $this->options;
 
 
-        $this->cursor = $this->collection->find($this->query, $options);
+        $this->cursor = $this->collection->find(TypeConverter::fromLegacy($this->query), $options);
     }
     }
 
 
     /**
     /**

+ 2 - 1
tests/Alcaeus/MongoDbAdapter/MongoCursorTest.php

@@ -1,6 +1,7 @@
 <?php
 <?php
 
 
 namespace Alcaeus\MongoDbAdapter\Tests;
 namespace Alcaeus\MongoDbAdapter\Tests;
+use Alcaeus\MongoDbAdapter\TypeConverter;
 use MongoDB\Driver\ReadPreference;
 use MongoDB\Driver\ReadPreference;
 use MongoDB\Operation\Find;
 use MongoDB\Operation\Find;
 
 
@@ -50,7 +51,7 @@ class MongoCursorTest extends TestCase
         $collectionMock
         $collectionMock
             ->expects($this->once())
             ->expects($this->once())
             ->method('find')
             ->method('find')
-            ->with($this->equalTo($query), $this->callback($checkOptionCallback))
+            ->with($this->equalTo(TypeConverter::fromLegacy($query)), $this->callback($checkOptionCallback))
             ->will($this->returnValue(new \ArrayIterator([])));
             ->will($this->returnValue(new \ArrayIterator([])));
 
 
         $collection = $this->getCollection('test');
         $collection = $this->getCollection('test');