Skip to content

Commit

Permalink
Merge pull request #7881 from cakephp/fix-sql-server
Browse files Browse the repository at this point in the history
Fix SQLServer
  • Loading branch information
markstory committed Dec 21, 2015
2 parents a026b0c + 56fe3b0 commit a32e327
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/ORM/EagerLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ public function contain($associations = [])

$associations = (array)$associations;
$associations = $this->_reformatContain($associations, $this->_containments);
$this->_normalized = $this->_loadExternal = null;
$this->_normalized = null;
$this->_loadExternal = [];
$this->_aliasList = [];
return $this->_containments = $associations;
}
Expand All @@ -152,7 +153,8 @@ public function contain($associations = [])
public function clearContain()
{
$this->_containments = [];
$this->_normalized = $this->_loadExternal = null;
$this->_normalized = null;
$this->_loadExternal = [];
$this->_aliasList = [];
}

Expand Down Expand Up @@ -366,6 +368,7 @@ public function attachableAssociations(Table $repository)
$contain = $this->normalized($repository);
$matching = $this->_matching ? $this->_matching->normalized($repository) : [];
$this->_fixStrategies();
$this->_loadExternal = [];
return $this->_resolveJoins($contain, $matching);
}

Expand Down
10 changes: 8 additions & 2 deletions tests/TestCase/ORM/QueryRegressionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1217,16 +1217,22 @@ public function testCountWithComplexOrderBy()
{
$table = TableRegistry::get('Articles');
$query = $table->find();
$query->orderDesc($query->newExpr()->add(['id' => 3]));
$query->orderDesc($query->newExpr()->addCase(
[$query->newExpr()->add(['id' => 3])],
[1, 0]
));
$query->order(['title' => 'desc']);
// Executing the normal query before getting the count
$query->all();
$this->assertEquals(3, $query->count());

$table = TableRegistry::get('Articles');
$query = $table->find();
$query->orderDesc($query->newExpr()->addCase(
[$query->newExpr()->add(['id' => 3])],
[1, 0]
));
$query->orderDesc($query->newExpr()->add(['id' => 3]));
$query->order(['title' => 'desc']);
// Not executing the query first, just getting the count
$this->assertEquals(3, $query->count());
}
Expand Down

0 comments on commit a32e327

Please sign in to comment.