etrepat / baum

Baum is an implementation of the Nested Set pattern for Laravel's Eloquent ORM.
http://etrepat.com/baum
MIT License
2.24k stars 459 forks source link

[BUG] Delete does not work properly #292

Open psychonetic opened 6 years ago

psychonetic commented 6 years ago

Hello,

there is a problem when deleting nodes.

Following example: root child0 child1 child2 child3

If you try to delete child2 and child3 there is no problem. If you try to delete node child0 or child1 it won't work. The problem is the ordering of this query: delete from tags where lft > 17 and rgt < 30 order by tags.lft asc

(Note: I delete records like suggested in the documentation: Tag::find($myId)->delete();

Which results in something like this: General error: 1032 Can't find record in 'tags'

Why do you sort those elements if you delete them? I don't see any advantage. If you remove the sorting, there wouldn't be an issue.

krychu90 commented 6 years ago

Confirmed! Baum version: 1.1.1