Browse Source

Fixing __debugInfo for the query

Jose Lorenzo Rodriguez 11 years ago
parent
commit
69a6f1085e
3 changed files with 8 additions and 5 deletions
  1. 3 3
      src/ORM/Association.php
  2. 3 1
      src/ORM/Query.php
  3. 2 1
      tests/TestCase/ORM/QueryTest.php

+ 3 - 3
src/ORM/Association.php

@@ -664,15 +664,15 @@ abstract class Association {
  * @return void
  */
 	protected function _bindNewAssociations($query, $surrogate, $options) {
-		$contain = $surrogate->contain();
-		$matching = $surrogate->eagerLoader()->matching();
+		$loader = $surrogate->eagerLoader();
+		$contain = $loader->contain();
+		$matching = $loader->matching();
 		$target = $this->_targetTable;
 
 		if (!$contain && !$matching) {
 			return;
 		}
 
-		$loader = $surrogate->eagerLoader();
 		$loader->attachAssociations($query, $target, $options['includeFields']);
 		$newContain = [];
 		foreach ($contain as $alias => $value) {

+ 3 - 1
src/ORM/Query.php

@@ -796,12 +796,14 @@ class Query extends DatabaseQuery implements JsonSerializable {
  * {@inheritDoc}
  */
 	public function __debugInfo() {
+		$eagerLoader = $this->eagerLoader();
 		return parent::__debugInfo() + [
 			'hydrate' => $this->_hydrate,
 			'buffered' => $this->_useBufferedResults,
 			'formatters' => count($this->_formatters),
 			'mapReducers' => count($this->_mapReduce),
-			'contain' => $this->contain(),
+			'contain' => $eagerLoader->contain(),
+			'matching' => $eagerLoader->matching(),
 			'extraOptions' => $this->_options,
 			'repository' => $this->_repository
 		];

+ 2 - 1
tests/TestCase/ORM/QueryTest.php

@@ -1895,7 +1895,8 @@ class QueryTest extends TestCase {
 			'buffered' => false,
 			'formatters' => 1,
 			'mapReducers' => 1,
-			'contain' => [
+			'contain' => [],
+			'matching' => [
 				'articles' => [
 					'queryBuilder' => null,
 					'matching' => true