Browse Source

Using de default column types for binding condition params for
associations

Jose Lorenzo Rodriguez 12 years ago
parent
commit
edcaeeac90
2 changed files with 8 additions and 8 deletions
  1. 3 3
      src/ORM/Association.php
  2. 5 5
      tests/TestCase/ORM/Association/BelongsToManyTest.php

+ 3 - 3
src/ORM/Association.php

@@ -417,9 +417,8 @@ abstract class Association {
 			}
 		}
 
-		$options['conditions'] = $query->newExpr()->add($options['conditions']);
+		
 		$dummy = $target->query()->eagerLoaded(true);
-
 		if (!empty($options['queryBuilder'])) {
 			$dummy = $options['queryBuilder']($dummy);
 			if (!($dummy instanceof Query)) {
@@ -433,7 +432,8 @@ abstract class Association {
 		$this->_dispatchBeforeFind($dummy);
 
 		$joinOptions = ['table' => 1, 'conditions' => 1, 'type' => 1];
-		$options['conditions']->add($dummy->clause('where') ?: []);
+		$dummy->where($options['conditions']);
+		$options['conditions'] = $dummy->clause('where');
 		$query->join([$target->alias() => array_intersect_key($options, $joinOptions)]);
 
 		$this->_appendFields($query, $dummy, $options);

+ 5 - 5
tests/TestCase/ORM/Association/BelongsToManyTest.php

@@ -226,7 +226,7 @@ class BelongsToManyTest extends TestCase {
 			'Tags' => [
 				'conditions' => new QueryExpression([
 					'Tags.name' => 'cake'
-				]),
+				], ['Tags.name' => 'string']),
 				'type' => 'INNER',
 				'table' => 'tags'
 			]
@@ -273,7 +273,7 @@ class BelongsToManyTest extends TestCase {
 			'Tags' => [
 				'conditions' => new QueryExpression([
 					'Tags.name' => 'cake'
-				]),
+				], ['Tags.name' => 'string']),
 				'type' => 'INNER',
 				'table' => 'tags'
 			]
@@ -313,9 +313,9 @@ class BelongsToManyTest extends TestCase {
 		$query->expects($this->at(0))->method('join')->with([
 			'Tags' => [
 				'conditions' => new QueryExpression([
+					'a' => 1,
 					'Tags.name' => 'cake',
-					new QueryExpression(['a' => 1])
-				]),
+				], ['Tags.name' => 'string']),
 				'type' => 'INNER',
 				'table' => 'tags'
 			]
@@ -371,7 +371,7 @@ class BelongsToManyTest extends TestCase {
 			'Tags' => [
 				'conditions' => new QueryExpression([
 					'Tags.name' => 'cake'
-				]),
+				], ['Tags.name' => 'string']),
 				'type' => 'INNER',
 				'table' => 'tags'
 			]