Skip to content

Commit

Permalink
Merge pull request #11078 from creative-commoners/pulls/5/mariadb-uni…
Browse files Browse the repository at this point in the history
…t-test

MNT Add sort order to unit test so it passes with mariadb
  • Loading branch information
sabina-talipova authored Nov 28, 2023
2 parents c63dca3 + f814395 commit 654b793
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions tests/php/ORM/SQLSelectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1174,13 +1174,19 @@ public function provideWith()
'name' => 'hierarchy',
'query' => (
new SQLSelect(
['parent_id' => '"SQLSelectTestCteRecursive"."ParentID"'],
[
'parent_id' => '"SQLSelectTestCteRecursive"."ParentID"',
'sort_order' => 0,
],
"SQLSelectTestCteRecursive",
[['"SQLSelectTestCteRecursive"."ParentID" > 0 AND "SQLSelectTestCteRecursive"."Title" = ?' => 'child of child1']]
)
)->addUnion(
new SQLSelect(
'"SQLSelectTestCteRecursive"."ParentID"',
[
'"SQLSelectTestCteRecursive"."ParentID"',
'sort_order + 1',
],
// Note that we select both the CTE and the real table in the FROM statement.
// We could also select one of these and JOIN on the other.
['"hierarchy"', '"SQLSelectTestCteRecursive"'],
Expand All @@ -1194,6 +1200,7 @@ public function provideWith()
'selectFrom' => '"SQLSelectTestCteRecursive"',
'extraManipulations' => [
'addInnerJoin' => ['hierarchy', '"SQLSelectTestCteRecursive"."ID" = "hierarchy"."parent_id"'],
'setOrderBy' => ['sort_order', 'ASC'],
],
'expected' => [
['Title' => 'child1'],
Expand All @@ -1205,24 +1212,31 @@ public function provideWith()
'name' => 'hierarchy',
'query' => (
new SQLSelect(
'"SQLSelectTestCteRecursive"."ParentID"',
[
'"SQLSelectTestCteRecursive"."ParentID"',
0
],
"SQLSelectTestCteRecursive",
[['"SQLSelectTestCteRecursive"."ParentID" > 0 AND "SQLSelectTestCteRecursive"."Title" = ?' => 'child of child1']]
)
)->addUnion(
new SQLSelect(
'"SQLSelectTestCteRecursive"."ParentID"',
[
'"SQLSelectTestCteRecursive"."ParentID"',
'sort_order + 1'
],
['"hierarchy"', '"SQLSelectTestCteRecursive"'],
['"SQLSelectTestCteRecursive"."ParentID" > 0 AND "SQLSelectTestCteRecursive"."ID" = "hierarchy"."parent_id"']
),
SQLSelect::UNION_ALL
),
'cteFields' => ['parent_id'],
'cteFields' => ['parent_id', 'sort_order'],
'recursive' => true,
'selectFields' => ['"SQLSelectTestCteRecursive"."Title"'],
'selectFrom' => '"SQLSelectTestCteRecursive"',
'extraManipulations' => [
'addInnerJoin' => ['hierarchy', '"SQLSelectTestCteRecursive"."ID" = "hierarchy"."parent_id"'],
'setOrderBy' => ['sort_order', 'ASC'],
],
'expected' => [
['Title' => 'child1'],
Expand Down

0 comments on commit 654b793

Please sign in to comment.