laravel-nestedset icon indicating copy to clipboard operation
laravel-nestedset copied to clipboard

The tree got broken very frequently and deleting node triggers deleting of random records

Open ankitsinghdalal opened this issue 3 years ago • 1 comments

I went through the code, where I noticed that upon deleting the node the children are also got deleted, and the children are calculated based on _lft filed using between query.

When the tree is broken, the _lft field is creating a mess where the wrong records are fetched as children and are deleted.

update
  `post`
set
  `deleted_at` = '2022-06-15 13:55:22',
  `post`.`updated_at` = '2022-06-15 13:55:22'
where
  `post`.`_lft` between 4200
  and 6000
  and `post`.`deleted_at` is null

What would be a possible way to correctly tackle this.

ankitsinghdalal avatar Jun 16 '22 04:06 ankitsinghdalal

See #226; maybe do a fixtree before executing the delete?

dejury avatar Aug 31 '22 11:08 dejury