Pārlūkot izejas kodu

Merge remote branch 'kriswallsmith/mongodb/logger-null-fix'

* kriswallsmith/mongodb/logger-null-fix:
  [DoctrineMongoDBBundle] fixed logging of null values
Fabien Potencier 14 gadi atpakaļ
vecāks
revīzija
a46c2aa68c

+ 3 - 1
src/Symfony/Bundle/DoctrineMongoDBBundle/Logger/DoctrineMongoDBLogger.php

@@ -248,7 +248,9 @@ class DoctrineMongoDBLogger
                 $array = false;
             }
 
-            if (is_bool($value)) {
+            if (null === $value) {
+                $formatted = 'null';
+            } elseif (is_bool($value)) {
                 $formatted = $value ? 'true' : 'false';
             } elseif (is_numeric($value)) {
                 $formatted = $value;

+ 2 - 2
src/Symfony/Bundle/DoctrineMongoDBBundle/Tests/Logger/DoctrineMongoDBLoggerTest.php

@@ -42,8 +42,8 @@ class DoctrineMongoDBLoggerTest extends \PHPUnit_Framework_TestCase
             ),
             // find
             array(
-                array('db' => 'foo', 'collection' => 'bar', 'find' => true, 'query' => array(), 'fields' => array()),
-                array('use foo;', 'db.bar.find();'),
+                array('db' => 'foo', 'collection' => 'bar', 'find' => true, 'query' => array('foo' => null), 'fields' => array()),
+                array('use foo;', 'db.bar.find({ "foo": null });'),
             ),
         );
     }