Browse Source

Simplify return value.

ADmad 3 years ago
parent
commit
e2fc3a4494
3 changed files with 5 additions and 8 deletions
  1. 3 4
      src/Database/Driver.php
  2. 1 1
      src/Database/Query.php
  3. 1 3
      tests/TestCase/Database/DriverTest.php

+ 3 - 4
src/Database/Driver.php

@@ -599,16 +599,15 @@ abstract class Driver
      *
      * @param \Cake\Database\Query $query The query to compile.
      * @param \Cake\Database\ValueBinder $binder The value binder to use.
-     * @return array containing 2 entries. The first entity is the transformed query
-     * and the second one the compiled SQL.
+     * @return string The compiled SQL.
      */
-    public function compileQuery(Query $query, ValueBinder $binder): array
+    public function compileQuery(Query $query, ValueBinder $binder): string
     {
         $processor = $this->newCompiler();
         $translator = $this->queryTranslator($query->type());
         $query = $translator($query);
 
-        return [$query, $processor->compile($query, $binder)];
+        return $processor->compile($query, $binder);
     }
 
     /**

+ 1 - 1
src/Database/Query.php

@@ -261,7 +261,7 @@ abstract class Query implements ExpressionInterface, Stringable
             $binder->resetCount();
         }
 
-        return $this->getConnection()->getDriver()->compileQuery($this, $binder)[1];
+        return $this->getConnection()->getDriver()->compileQuery($this, $binder);
     }
 
     /**

+ 1 - 3
tests/TestCase/Database/DriverTest.php

@@ -246,9 +246,7 @@ class DriverTest extends TestCase
 
         $result = $driver->compileQuery($query, new ValueBinder());
 
-        $this->assertIsArray($result);
-        $this->assertSame($query, $result[0]);
-        $this->assertSame('1', $result[1]);
+        $this->assertSame('1', $result);
     }
 
     /**