From 7136f8fa1cc6108df90f6dd89033a785ff49a518 Mon Sep 17 00:00:00 2001 From: Lee Rowlands Date: Mon, 6 Feb 2017 18:25:09 +1000 Subject: [PATCH 1/2] Find children should order --- src/Storage/DbalNestedSet.php | 1 + tests/Functional/DbalNestedSetTest.php | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Storage/DbalNestedSet.php b/src/Storage/DbalNestedSet.php index ef6d1785..0cd5adec 100644 --- a/src/Storage/DbalNestedSet.php +++ b/src/Storage/DbalNestedSet.php @@ -137,6 +137,7 @@ public function findDescendants(Node $node, $depth = 0) { ->andWhere('parent.revision_id = :revision_id') ->andwhere('child.left_pos > parent.left_pos') ->andWhere('child.right_pos < parent.right_pos') + ->orderBy('left_pos', 'ASC') ->setParameter(':id', $node->getId()) ->setParameter(':revision_id', $node->getRevisionId()); if ($depth > 0) { diff --git a/tests/Functional/DbalNestedSetTest.php b/tests/Functional/DbalNestedSetTest.php index 65b794e1..f2f93f09 100644 --- a/tests/Functional/DbalNestedSetTest.php +++ b/tests/Functional/DbalNestedSetTest.php @@ -482,14 +482,6 @@ protected function loadTestData() { 'right_pos' => 7, 'depth' => 3, ]); - $this->connection->insert($this->tableName, - [ - 'id' => 7, - 'revision_id' => 1, - 'left_pos' => 11, - 'right_pos' => 16, - 'depth' => 2, - ]); $this->connection->insert($this->tableName, [ 'id' => 8, @@ -506,6 +498,14 @@ protected function loadTestData() { 'right_pos' => 20, 'depth' => 2, ]); + $this->connection->insert($this->tableName, + [ + 'id' => 7, + 'revision_id' => 1, + 'left_pos' => 11, + 'right_pos' => 16, + 'depth' => 2, + ]); $this->connection->insert($this->tableName, [ 'id' => 10, From 8377c36982d53dc0b7c80f3b26f7e0b4a8e11c68 Mon Sep 17 00:00:00 2001 From: Kim Pepper Date: Mon, 6 Feb 2017 20:44:13 +1100 Subject: [PATCH 2/2] Add table prefix --- src/Storage/DbalNestedSet.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Storage/DbalNestedSet.php b/src/Storage/DbalNestedSet.php index 0cd5adec..370ff37d 100644 --- a/src/Storage/DbalNestedSet.php +++ b/src/Storage/DbalNestedSet.php @@ -137,7 +137,7 @@ public function findDescendants(Node $node, $depth = 0) { ->andWhere('parent.revision_id = :revision_id') ->andwhere('child.left_pos > parent.left_pos') ->andWhere('child.right_pos < parent.right_pos') - ->orderBy('left_pos', 'ASC') + ->orderBy('child.left_pos', 'ASC') ->setParameter(':id', $node->getId()) ->setParameter(':revision_id', $node->getRevisionId()); if ($depth > 0) {