Skip to content

Commit be1c45d

Browse files
committed
Add sort conditions to normalize result ordering.
Postgres orders inconsistently without an explicit order. Set an order to keep results the same always.
1 parent 7818cde commit be1c45d

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/Cake/Test/TestCase/ORM/QueryTest.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,11 @@ public function testHasManyEagerLoading($strategy) {
312312
$query = new Query($this->connection);
313313
$table = Table::build('author', ['connection' => $this->connection]);
314314
Table::build('article', ['connection' => $this->connection]);
315-
$table->hasMany('article', ['property' => 'articles', 'strategy' => $strategy]);
315+
$table->hasMany('article', [
316+
'property' => 'articles',
317+
'strategy' => $strategy,
318+
'sort' => ['article.id' => 'asc']
319+
]);
316320

317321
$results = $query->repository($table)->select()->contain('article')->toArray();
318322
$expected = [
@@ -432,7 +436,11 @@ public function testHasManyEagerLoadingDeep($strategy) {
432436
$query = new Query($this->connection);
433437
$table = Table::build('author', ['connection' => $this->connection]);
434438
$article = Table::build('article', ['connection' => $this->connection]);
435-
$table->hasMany('article', ['property' => 'articles'] + compact('strategy'));
439+
$table->hasMany('article', [
440+
'property' => 'articles',
441+
'stratgey' => $strategy,
442+
'sort' => ['article.id' => 'asc']
443+
]);
436444
$article->belongsTo('author');
437445

438446
$results = $query->repository($table)

0 commit comments

Comments
 (0)