Browse Source

Test subqueries in conditions too.

ndm2 9 years ago
parent
commit
d3a84aaac3
1 changed files with 9 additions and 3 deletions
  1. 9 3
      tests/TestCase/Database/QueryTest.php

+ 9 - 3
tests/TestCase/Database/QueryTest.php

@@ -2841,7 +2841,6 @@ class QueryTest extends TestCase
      */
     public function testUpdateStripAliasesFromConditions()
     {
-        $this->loadFixtures('Authors');
         $query = new Query($this->connection);
 
         $query
@@ -2854,14 +2853,21 @@ class QueryTest extends TestCase
                         'b.name NOT IN' => ['foo', 'bar'],
                         'OR' => [
                             $query->newExpr()->eq(new IdentifierExpression('c.name'), 'zap'),
-                            'd.name' => 'baz'
+                            'd.name' => 'baz',
+                            (new Query($this->connection))->select(['e.name'])->where(['e.name' => 'oof'])
                         ]
                     ]
                 ],
             ]);
 
         $this->assertQuotedQuery(
-            'UPDATE <authors> SET <name> = :c0 WHERE \(<id> = :c1 OR \(<name> not in \(:c2,:c3\) AND \(\(<c>\.<name>\) = :c4 OR <name> = :c5\)\)\)',
+            'UPDATE <authors> SET <name> = :c0 WHERE \(' .
+                '<id> = :c1 OR \(' .
+                    '<name> not in \(:c2,:c3\) AND \(' .
+                        '\(<c>\.<name>\) = :c4 OR <name> = :c5 OR \(SELECT <e>\.<name> WHERE <e>\.<name> = :c6\)' .
+                    '\)' .
+                '\)' .
+            '\)',
             $query->sql(),
             !$this->autoQuote
         );