Browse Source

Also cloning the select type map when cloning the query

Jose Lorenzo Rodriguez 10 years ago
parent
commit
8bcfeb3a60
2 changed files with 9 additions and 1 deletions
  1. 4 1
      src/Database/Query.php
  2. 5 0
      tests/TestCase/Database/QueryTest.php

+ 4 - 1
src/Database/Query.php

@@ -1790,9 +1790,12 @@ class Query implements ExpressionInterface, IteratorAggregate
     public function __clone()
     {
         $this->_iterator = null;
-        if ($this->_valueBinder) {
+        if ($this->_valueBinder !== null) {
             $this->_valueBinder = clone $this->_valueBinder;
         }
+        if ($this->_selectTypeMap !== null) {
+            $this->_selectTypeMap = clone $this->_selectTypeMap;
+        }
         foreach ($this->_parts as $name => $part) {
             if (empty($part)) {
                 continue;

+ 5 - 0
tests/TestCase/Database/QueryTest.php

@@ -3487,6 +3487,11 @@ class QueryTest extends TestCase
 
         $query->order(['Articles.title' => 'ASC']);
         $this->assertNotEquals($query->clause('order'), $dupe->clause('order'));
+
+        $this->assertNotSame(
+            $query->selectTypeMap(),
+            $dupe->selectTypeMap()
+        );
     }
 
     /**