diff --git a/src/Storage/DbalNestedSet.php b/src/Storage/DbalNestedSet.php index ef6d1785..370ff37d 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('child.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,