Repository navigation
Fix move_before to the leftmost child position - #122
Open
arancool3000 wants to merge 1 commit into
Open
arancool3000 wants to merge 1 commit into
arancool3000 wants to merge 1 commit into
Conversation
move_before on a parent's first child returned early without moving, and the left-sibling lookup could pick a same-level cousin from another subtree. Restrict the lookup to the same parent, order by lft, and insert as the leftmost child when there is no left sibling. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
node.move_before(x)wherexis the first child of its parent did nothing (#68). The left-sibling search also ignoredparent_idand had noORDER BY, so a same-level cousin from another subtree could be taken as the left sibling and the node moved under the wrong parent.Fix
In
mptt_before_update(events.py): filter the left-sibling query by the target's parent and order bylft; when there is no left sibling and the target has a parent, set the node's parent to it and skip the "no move" early return so the existing insert-as-first-child path runs.Tests
test_move_before_leftmost_child(moves node 6 before node 5, with cousin node 3 at the same level to the left). It fails on master and passes with the fix. Full suite: 297 passed, 1 xfailed (master: 291 passed). flake8 clean.Fixes #68
AI-assisted (Claude); reviewed before submission.