Potential fix for #719, #1001: data loss when reordering items in upward direction #1002
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I got some issue with this (#719, #1001) as well.
With that fix, I haven't been able to reproduce the bug.
Description of the fix
In my testing, it happens only when items have duplicate IDs (though I haven't been able to understand why):
And this happens at least if items are copied and pasted (or dragged and dropped with
CTRL
).The issue comes from here:
manuskript/manuskript/models/abstractModel.py
Lines 429 to 441 in 0182a43
Since
getUniqueID
does not do anything if item has no model:manuskript/manuskript/models/abstractItem.py
Lines 207 to 215 in 0182a43
and at that moment in the drop, items have no models.
Well, the easier fix here is to simply remove items IDs, so they get new ones when theyre created, which this commit does.
Further things to consider
IF this effectiverly fixes this bug, in my mind the
WARNING> There are some items with overlapping IDs:
should be treated with more seriousness. It shouldn't be allowed that IDs are not unique.