Skip to content

Commit 563b3b6

Browse files
author
Sartor
committed
Union stable behavior fix
1 parent 014c0ad commit 563b3b6

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

tests/QueryTest.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,23 +117,28 @@ public function testSubQuery()
117117
public function testUnionAll()
118118
{
119119
$db = $this->getConnection();
120-
$secondQuery = (new Query())
120+
$query1 = (new Query())
121121
->select('name')
122122
->from('{{customer}}')
123123
->where([
124124
'id' => [1]
125125
]);
126126

127-
$rows = (new Query())
127+
$query2 = (new Query())
128128
->select('name')
129129
->from('{{customer}}')
130130
->where([
131131
'id' => [2]
132-
])
133-
->union($secondQuery, true)
132+
]);
133+
134+
$rows = (new Query())
135+
->select('name')
136+
->from(['result' => $query1->union($query2, true)])
134137
->orderBy(['name' => SORT_ASC])
135138
->all($db);
136139

140+
// Using Subquery, because of ClickHouse does not sort result
141+
137142
$this->assertEquals([
138143
['name' => 'user1'],
139144
['name' => 'user2']

0 commit comments

Comments
 (0)