Skip to content

Commit

Permalink
Add sort conditions to normalize result ordering.
Browse files Browse the repository at this point in the history
Postgres orders inconsistently without an explicit order. Set an order
to keep results the same always.
  • Loading branch information
markstory committed Jun 28, 2013
1 parent 7818cde commit be1c45d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/Cake/Test/TestCase/ORM/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,11 @@ public function testHasManyEagerLoading($strategy) {
$query = new Query($this->connection);
$table = Table::build('author', ['connection' => $this->connection]);
Table::build('article', ['connection' => $this->connection]);
$table->hasMany('article', ['property' => 'articles', 'strategy' => $strategy]);
$table->hasMany('article', [
'property' => 'articles',
'strategy' => $strategy,
'sort' => ['article.id' => 'asc']
]);

$results = $query->repository($table)->select()->contain('article')->toArray();
$expected = [
Expand Down Expand Up @@ -432,7 +436,11 @@ public function testHasManyEagerLoadingDeep($strategy) {
$query = new Query($this->connection);
$table = Table::build('author', ['connection' => $this->connection]);
$article = Table::build('article', ['connection' => $this->connection]);
$table->hasMany('article', ['property' => 'articles'] + compact('strategy'));
$table->hasMany('article', [
'property' => 'articles',
'stratgey' => $strategy,
'sort' => ['article.id' => 'asc']
]);
$article->belongsTo('author');

$results = $query->repository($table)
Expand Down

0 comments on commit be1c45d

Please sign in to comment.