Browse Source

Always map association fields.

This ensures that association fields are in the typemap to cover cases
where fields are used in conditions for the matching() clause.

Refs #8147
Mark Story 10 years ago
parent
commit
501358c7a9
2 changed files with 2 additions and 2 deletions
  1. 1 1
      src/ORM/Association.php
  2. 1 1
      tests/TestCase/ORM/EagerLoaderTest.php

+ 1 - 1
src/ORM/Association.php

@@ -719,8 +719,8 @@ abstract class Association
 
         if (!empty($fields)) {
             $query->select($query->aliasFields($fields, $target->alias()));
-            $query->addDefaultTypes($target);
         }
+        $query->addDefaultTypes($target);
     }
 
     /**

+ 1 - 1
tests/TestCase/ORM/EagerLoaderTest.php

@@ -170,7 +170,7 @@ class EagerLoaderTest extends TestCase
                 'type' => 'LEFT',
                 'conditions' => new QueryExpression([
                     ['clients.id' => new IdentifierExpression('foo.client_id')],
-                ], $this->clientsTypeMap)
+                ], new TypeMap($this->clientsTypeMap->defaults()))
             ]])
             ->will($this->returnValue($query));