-
Notifications
You must be signed in to change notification settings - Fork 470
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
Set is broken but fixTree return null #82
Comments
Please provide an output of |
Sorry for the late response. Here's my result from tinker Psy Shell v0.6.1 (PHP 7.0.1-1+deb.sury.org~trusty+2 — cli) by Justin Hileman
>>> FooBar::isBroken()
=> true
>>> FooBar:: countErrors()
=> [
"oddness" => 5,
"duplicates" => 20,
"wrong_parent" => 0,
]
>>> FooBar::fixTree()
=> null |
Are you using soft deletes? |
No, I'm not. Could you explain |
Run this query: |
There are 5 rows. They share the same |
I guess the only reason of this issue is that those nodes have |
Well, they are, indeed. I should have checked the parent sooner, sorry. Thank you so much ! |
I think those nodes should be saved as roots when fixing the tree. Also, setting up a foreign key would be nice |
@lazychaser In my case, the |
@lazychaser Sorry, I know this is OT but I'm unable to add the foreign key to the current schema of the set. Any advices? alter table `foo_bar` add constraint foobar_parent_id_foreign foreign key (`parent_id`) references `foo_bar` (`id`) on delete cascade;
|
This means that there are still nodes that have invalid parent_id value. This might help: select * from foo_bar where parent_id is not null and not exists (select 1 from foo_bar p where p.id = foo_bar.parent_id) This query will display nodes pointing to invalid parents. |
@lazychaser Thank you so much. It's clear now ! |
Great, glad to help |
I have a nested set which contains about 5200 nodes. The
isBroken()
it returnstrue
butfixTree()
always returnsnull
. Is there any problem with a large set?The text was updated successfully, but these errors were encountered: