Skip to content
Permalink
Browse files

Add sort conditions to normalize result ordering.

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 be1c45d148fb2c3e49a689917bd1516c211d928b
Showing with 10 additions and 2 deletions.
  1. +10 −2 lib/Cake/Test/TestCase/ORM/QueryTest.php
@@ -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 = [
@@ -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)

0 comments on commit be1c45d

Please sign in to comment.
You can’t perform that action at this time.