Ticket #1126 (closed defect: fixed)
createRoot() should use the $model->id instead of a straight MAX()
| Reported by: | slickrick | Owned by: | romanb |
|---|---|---|---|
| Priority: | minor | Milestone: | |
| Component: | NestedSet | Version: | 1.0.0 |
| Severity: | Keywords: | ||
| Cc: | Has Test: | no | |
| Status: | Pending Core Response | Has Patch: | no |
Description
When you call $tree->createRoot($model), it uses MAX() to find the next root_id. This can causes issues when you have an autoincrement table because the id and root_id end up not being the same.
Instead, Doctrine should look for the $model->id to use as the new root_id. If it's not persistant, Doctrine should save the $model and then use the id. This will save a lot of headache down the road when trying to get the actual root node without multiple queries.
Change History
Note: See
TracTickets for help on using
tickets.