Krishna,<br><br>That worked GREAT! Thanks for such a wonderful library! :D<br><br>Thanks,<br><br>--<br>Matt<br><br><div><span class="gmail_quote">On 8/14/07, <b class="gmail_sendername">Krishna Dole</b> <<a href="mailto:dontfall@gmail.com">
dontfall@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hey Matt,<br><br>You were right-- there was a bug in the renumbering when working with
<br>virtual roots. I have fixed it in trunk. You can get the fixed version<br>with<br><br>script/plugin install svn://rubyforge.org/var/svn/betternestedset/trunk<br><br>Thanks for reporting this.<br><br>Krishna<br><br>On 8/14/07, Matt Rogish <
<a href="mailto:rogishmn@muohio.edu">rogishmn@muohio.edu</a>> wrote:<br>> My guess is that there's a bug in the implementation of<br>> renumber_full_tree/calc_numbers which is causing this problem. The dataset
<br>> with overlapping numbers is what resulted from applying renumber_full_tree;<br>> thus something is not quite right with that method...<br>><br>> I have a copy of SQL for Smarties (2nd ed), so I'll try and see if the two
<br>> algorithms diverge at all and/or provide a patch if I can help it. :)<br>><br>> Thanks,<br>><br>> --<br>> Matt<br>><br>><br>> On 8/14/07, Matt Rogish <<a href="mailto:matt.rogish@gmail.com">
matt.rogish@gmail.com</a>> wrote:<br>> ><br>> > The problem is, as I see it, overlapping left and right columns. Shouldn't<br>> the lft/right be one apart, or am I wrong.<br>> ><br>> > For example:
<br>> > mysql> select id, parent_id, lft, rgt from messages where message_board_id<br>> = 1926 and parent_id is null order by lft;<br>> > +--------+-----------+------+------+<br>> > | id | parent_id | lft | rgt |
<br>> > +--------+-----------+------+------+<br>> > | 9472 | NULL | 1 | 2 |<br>> > | 9473 | NULL | 2 | 37 |<br>> > | 9474 | NULL | 37 | 44 |<br>> > | 9475 | NULL | 44 | 45 |
<br>> > | 9476 | NULL | 45 | 74 |<br>> > | 9477 | NULL | 74 | 75 |<br>> > | 9478 | NULL | 75 | 114 |<br>> > | 9487 | NULL | 114 | 179 |<br>> > | 9479 | NULL | 179 | 348 |
<br>> > | 9488 | NULL | 478 | 515 |<br>> > | 9482 | NULL | 515 | 520 |<br>> > | 9483 | NULL | 520 | 525 |<br>> > | 9484 | NULL | 525 | 526 |<br>> > | 9485 | NULL | 526 | 579 |
<br>> > | 334881 | NULL | 579 | 580 |<br>> > | 335201 | NULL | 581 | 584 |<br>> > | 335234 | NULL | 585 | 586 |<br>> > +--------+-----------+------+------+<br>> ><br>> > So the only ones "correct" are id = 335201 and id = 335234?
<br>> ><br>> > I attached the entire dataset. What is happening is that the BETWEEN<br>> statement that better nested set is executing looks something like this:<br>> > m = Message.find( 9478 )<br>> >
m.all_children.each{ stuff }<br>> ><br>> > SQL is:<br>> > SELECT * FROM messages WHERE (message_board_id = 1926 AND (lft BETWEEN 75<br>> AND 114)) ORDER BY lf<br>> ><br>> > Since BETWEEN is inclusive, that result pulls all the children correctly
<br>> but incorrectly pulls out the next root, message id = 9487.<br>> ><br>> > I'm not sure if that means renumber_entire_tree needs to be fixed, or the<br>> actual move_to_child does, but something isn't right.
<br>> ><br>> ><br>> > --<br>> ><br>> > Matt<br>> ><br>> ><br>> > On 8/14/07, Matt Rogish <<a href="mailto:rogishmn@muohio.edu">rogishmn@muohio.edu</a>> wrote:<br>> > > I'm not writing any SQL, I'm using built-in better-nested-set functions.
<br>> > ><br>> > > Here's my save:<br>> > > def create<br>> > > @message = Message.new(params[:message])<br>> > ><br>> > > if @message.save<br>> > > flash[:notice] = 'Message was successfully created.'
<br>> > ><br>> > > if params[:message][:parent_id]<br>> > > @message.move_to_child_of( Message.find<br>> params[:message][:parent_id] )<br>> > > @message.save<br>
> > > end<br>> > > end<br>> > > end<br>> > ><br>> > > --<br>> > > Matt<br>> > ><br>> > ><br>> > ><br>> > > On 8/14/07, Jeremy Nicoll <
<a href="mailto:jnicoll@goldnoteexpress.com">jnicoll@goldnoteexpress.com</a> > wrote:<br>> > > ><br>> > > > I think it would be best if you could post your SQL that is messed<br>> up as well as the code you are using to save your nodes. Unfortunately we
<br>> can't tell you what is wrong until we actually see the logic behind what you<br>> are doing.<br>> > > ><br>> > > > --<br>> > > > Jeremy Nicoll<br>> > > ><br>
> > > > Matt Rogish wrote:<br>> > > ><br>> > > > How can I repair my tree?<br>> > > ><br>> > > > I have a message board system in which the messages are grouped by
<br>> "message_board_id", thus my model is:<br>> > > > acts_as_nested_set :scope => :message_board_id<br>> > > ><br>> > > > Somehow the tree is messed up, inasmuch as some roots (parent_id ==
<br>> null) are being set to the children of some other message, so I cannot<br>> successfully repair it. I'm not sure if I'm performing incorrect operations<br>> or what, but somehow I need to repair my tree where message_board_id = 34
<br>> (or whatever it is).<br>> > > ><br>> > > > It seems as if renumber_full_tree tries to find the virtual root for a<br>> given node, but since the root itself is a CHILD of another node, the whole
<br>> thing fails. My layman's guess is that the "root" condition is wrong, since<br>> it's doing WHERE parent_id IS NULL ... AND lft BETWEEN .. AND ..<br>> > > ><br>> > > > Well, if the root is incorrectly between something, then the lft would
<br>> fail, no? Maybe I'm misreading that. Help!!<br>> > > ><br>> > > > Thanks,<br>> > > ><br>> > > > --<br>> > > > Matt<br>> > > ><br>> > > >
<br>> > > > On 8/14/07, Matt Rogish <<a href="mailto:rogishmn@muohio.edu">rogishmn@muohio.edu</a>> wrote:<br>> > > > > Under heavy load we are getting significantly screwed up data. I<br>> have to run renumber_full_tree in script/console production order to repair
<br>> the thing.<br>> > > > ><br>> > > > > Obviously this is a bad thing, but I don't even know where to start<br>> to fix it. Any ideas?<br>> > > > ><br>> > > > > Thanks,
<br>> > > > ><br>> > > > > --<br>> > > > > Matt<br>> > > > ><br>> > > ><br>> > > > ________________________________<br>><br>> > > > _______________________________________________
<br>> > > > Betternestedset-talk mailing list<br>> > > > <a href="mailto:Betternestedset-talk@rubyforge.org">Betternestedset-talk@rubyforge.org</a><br>> > > ><br>> > > ><br>
> > > ><br>> > > ><br>> > > ><br>> <a href="http://rubyforge.org/mailman/listinfo/betternestedset-talk">http://rubyforge.org/mailman/listinfo/betternestedset-talk</a><br>> > > >
<br>> > > ><br>> > > > _______________________________________________<br>> > > > Betternestedset-talk mailing list<br>> > > > <a href="mailto:Betternestedset-talk@rubyforge.org">
Betternestedset-talk@rubyforge.org</a><br>> > > ><br>> <a href="http://rubyforge.org/mailman/listinfo/betternestedset-talk">http://rubyforge.org/mailman/listinfo/betternestedset-talk</a><br>> > > >
<br>> > > ><br>> > ><br>> > ><br>> ><br>> ><br>> ><br>><br>><br>> _______________________________________________<br>> Betternestedset-talk mailing list<br>>
<a href="mailto:Betternestedset-talk@rubyforge.org">Betternestedset-talk@rubyforge.org</a><br>> <a href="http://rubyforge.org/mailman/listinfo/betternestedset-talk">http://rubyforge.org/mailman/listinfo/betternestedset-talk
</a><br>><br>><br>_______________________________________________<br>Betternestedset-talk mailing list<br><a href="mailto:Betternestedset-talk@rubyforge.org">Betternestedset-talk@rubyforge.org</a><br><a href="http://rubyforge.org/mailman/listinfo/betternestedset-talk">
http://rubyforge.org/mailman/listinfo/betternestedset-talk</a><br></blockquote></div><br>