mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #11078 from creative-commoners/pulls/5/mariadb-unit-test
MNT Add sort order to unit test so it passes with mariadb
This commit is contained in:
commit
654b793780
@ -1174,13 +1174,19 @@ class SQLSelectTest extends SapphireTest
|
|||||||
'name' => 'hierarchy',
|
'name' => 'hierarchy',
|
||||||
'query' => (
|
'query' => (
|
||||||
new SQLSelect(
|
new SQLSelect(
|
||||||
['parent_id' => '"SQLSelectTestCteRecursive"."ParentID"'],
|
[
|
||||||
|
'parent_id' => '"SQLSelectTestCteRecursive"."ParentID"',
|
||||||
|
'sort_order' => 0,
|
||||||
|
],
|
||||||
"SQLSelectTestCteRecursive",
|
"SQLSelectTestCteRecursive",
|
||||||
[['"SQLSelectTestCteRecursive"."ParentID" > 0 AND "SQLSelectTestCteRecursive"."Title" = ?' => 'child of child1']]
|
[['"SQLSelectTestCteRecursive"."ParentID" > 0 AND "SQLSelectTestCteRecursive"."Title" = ?' => 'child of child1']]
|
||||||
)
|
)
|
||||||
)->addUnion(
|
)->addUnion(
|
||||||
new SQLSelect(
|
new SQLSelect(
|
||||||
|
[
|
||||||
'"SQLSelectTestCteRecursive"."ParentID"',
|
'"SQLSelectTestCteRecursive"."ParentID"',
|
||||||
|
'sort_order + 1',
|
||||||
|
],
|
||||||
// Note that we select both the CTE and the real table in the FROM statement.
|
// 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.
|
// We could also select one of these and JOIN on the other.
|
||||||
['"hierarchy"', '"SQLSelectTestCteRecursive"'],
|
['"hierarchy"', '"SQLSelectTestCteRecursive"'],
|
||||||
@ -1194,6 +1200,7 @@ class SQLSelectTest extends SapphireTest
|
|||||||
'selectFrom' => '"SQLSelectTestCteRecursive"',
|
'selectFrom' => '"SQLSelectTestCteRecursive"',
|
||||||
'extraManipulations' => [
|
'extraManipulations' => [
|
||||||
'addInnerJoin' => ['hierarchy', '"SQLSelectTestCteRecursive"."ID" = "hierarchy"."parent_id"'],
|
'addInnerJoin' => ['hierarchy', '"SQLSelectTestCteRecursive"."ID" = "hierarchy"."parent_id"'],
|
||||||
|
'setOrderBy' => ['sort_order', 'ASC'],
|
||||||
],
|
],
|
||||||
'expected' => [
|
'expected' => [
|
||||||
['Title' => 'child1'],
|
['Title' => 'child1'],
|
||||||
@ -1205,24 +1212,31 @@ class SQLSelectTest extends SapphireTest
|
|||||||
'name' => 'hierarchy',
|
'name' => 'hierarchy',
|
||||||
'query' => (
|
'query' => (
|
||||||
new SQLSelect(
|
new SQLSelect(
|
||||||
|
[
|
||||||
'"SQLSelectTestCteRecursive"."ParentID"',
|
'"SQLSelectTestCteRecursive"."ParentID"',
|
||||||
|
0
|
||||||
|
],
|
||||||
"SQLSelectTestCteRecursive",
|
"SQLSelectTestCteRecursive",
|
||||||
[['"SQLSelectTestCteRecursive"."ParentID" > 0 AND "SQLSelectTestCteRecursive"."Title" = ?' => 'child of child1']]
|
[['"SQLSelectTestCteRecursive"."ParentID" > 0 AND "SQLSelectTestCteRecursive"."Title" = ?' => 'child of child1']]
|
||||||
)
|
)
|
||||||
)->addUnion(
|
)->addUnion(
|
||||||
new SQLSelect(
|
new SQLSelect(
|
||||||
|
[
|
||||||
'"SQLSelectTestCteRecursive"."ParentID"',
|
'"SQLSelectTestCteRecursive"."ParentID"',
|
||||||
|
'sort_order + 1'
|
||||||
|
],
|
||||||
['"hierarchy"', '"SQLSelectTestCteRecursive"'],
|
['"hierarchy"', '"SQLSelectTestCteRecursive"'],
|
||||||
['"SQLSelectTestCteRecursive"."ParentID" > 0 AND "SQLSelectTestCteRecursive"."ID" = "hierarchy"."parent_id"']
|
['"SQLSelectTestCteRecursive"."ParentID" > 0 AND "SQLSelectTestCteRecursive"."ID" = "hierarchy"."parent_id"']
|
||||||
),
|
),
|
||||||
SQLSelect::UNION_ALL
|
SQLSelect::UNION_ALL
|
||||||
),
|
),
|
||||||
'cteFields' => ['parent_id'],
|
'cteFields' => ['parent_id', 'sort_order'],
|
||||||
'recursive' => true,
|
'recursive' => true,
|
||||||
'selectFields' => ['"SQLSelectTestCteRecursive"."Title"'],
|
'selectFields' => ['"SQLSelectTestCteRecursive"."Title"'],
|
||||||
'selectFrom' => '"SQLSelectTestCteRecursive"',
|
'selectFrom' => '"SQLSelectTestCteRecursive"',
|
||||||
'extraManipulations' => [
|
'extraManipulations' => [
|
||||||
'addInnerJoin' => ['hierarchy', '"SQLSelectTestCteRecursive"."ID" = "hierarchy"."parent_id"'],
|
'addInnerJoin' => ['hierarchy', '"SQLSelectTestCteRecursive"."ID" = "hierarchy"."parent_id"'],
|
||||||
|
'setOrderBy' => ['sort_order', 'ASC'],
|
||||||
],
|
],
|
||||||
'expected' => [
|
'expected' => [
|
||||||
['Title' => 'child1'],
|
['Title' => 'child1'],
|
||||||
|
Loading…
Reference in New Issue
Block a user