-
Notifications
You must be signed in to change notification settings - Fork 247
Fix root node siblings not reordered after prepend_child/add_sibling moves root to child position #482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…moves a root to child position Co-authored-by: seuros <2394703+seuros@users.noreply.github.com>
Co-authored-by: seuros <2394703+seuros@users.noreply.github.com>
| was_root = prior_parent.nil? && child_node.persisted? | ||
| child_node.order_value = -1 | ||
| child_node.parent = self | ||
| child_node._ct_skip_sort_order_maintenance! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: I’m trying to understand the need for skip_sort_order_maintenance in prepend_child. My understanding is that prepend_child is only used when moving a node from one parent/root to another. In that scenario, wouldn’t the normal flow where after_save triggers rebuild!— already handle the sort order correctly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR was generated from #481 .
I just wanted to see if @copilot will nail the edge-cases in a library that is well known in its dataset.
Basically Copilot shipped vibe code that pass the tests, but you can see that it could not run test because of the firewall.
Test are wrong because we need to test the same pattern in 3 records
Label For postgres
MemoryTag for sqlite
and any other mysql record.
Only then we can release a new version.
If you want to pickup it, go ahead. The docker compose will give you everything you need, and feel free to to ping me here if you need clarification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes @seuros I did went through the #481 issue. I was looking more closely at the existing implementation in prepend_child, specifically the call to child_node._ct_skip_sort_order_maintenance!, which seems to be the reason this issue occurs. I wanted to better understand the need for this, since prepend_child is only used to move a node to a different parent, and in that case _ct_skip_sort_order_maintenance doesn’t seem to make sense. I may be misunderstanding the intent here.
Moving a root node to become a child via
prepend_childoradd_siblingleaves gaps inorder_valuesequence among remaining roots. The_ct_skip_sort_order_maintenance!flag prevents the normal reordering callback, but neither method was explicitly reordering the old parent's siblings afterward.Changes
_ct_reorder_prior_parent_or_roots: Reorders either the prior parent's children or root siblings (when root ordering is enabled)prepend_child: Tracks prior parent before move, calls helper after saveadd_sibling: Tracks if sibling was root, uses helper instead ofprior_sibling_parent.try(:_ct_reorder_children)Example
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
api.launchpad.net/usr/bin/add-apt-repository add-apt-repository -y ppa:brightbox/ruby-ng(dns block)esm.ubuntu.com/usr/lib/apt/methods/https /usr/lib/apt/methods/https(dns block)mise.run/usr/bin/curl curl -fsSL REDACTED(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.