awesome_nested_set icon indicating copy to clipboard operation
awesome_nested_set copied to clipboard

Validate lft and rgt should be less then max sequence

Open sampatbadhe opened this issue 2 years ago • 5 comments

Validate lft and rgt should be less then max sequence which is (number of records * 2)

i.e.

category1 = { parent_id: nil, lft: 1, rgt: 2 }
category2 = { parent_id: nil, lft: 3, rgt: 4 }
category3 = { parent_id: nil, lft: 9, rgt: 10 }

In above case, Category.valid? returns true, but expecting to return false so that it can rebuild again to correct the sequence.

Please feel free to close this PR if my changes looks invalid, as I noticed the scenario which I mentioned was considered as valid case and covered in spec that way.

sampatbadhe avatar Jun 07 '23 14:06 sampatbadhe

Interesting. What do you think @danielmorrison ? This was merged by you from #241

parndt avatar Jun 08 '23 22:06 parndt

I'd still like to hear from @danielmorrison / @shekibobo if possible please 😄

parndt avatar Jun 11 '23 09:06 parndt

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Aug 09 '23 22:08 stale[bot]

@botandrose what do you think about this PR?

parndt avatar Mar 08 '24 01:03 parndt

@parndt Hmm, my first thought is curiosity about the motivation behind the PR. @sampatbadhe did you find yourself in a situation where lft and rgt were outside of the max sequence? How did this happen?

botandrose avatar Mar 08 '24 18:03 botandrose

Thank you for checking @botandrose & @parndt

Upon reviewing the our database today, I didn't find any records where "lft" and "rgt" were outside the maximum sequence. However, there were some records earlier that had this issue, which I manually corrected a while ago. Closing this PR as its no longer an issue.

sampatbadhe avatar May 12 '24 06:05 sampatbadhe