change undo stack processing order to created-modified-removed #32
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.
With current undo stacks processing order: modified, created, removed, there will be a dead loop for the following example code.
So we need to change the undo stacks processing order to created, modified, removed. The issue in above code can be fixed.
Actually there are four cases to make the unique key conflict. Say we have two records (A, B) in one table which has unique key. The four cases are:
With original undo stack processing order (modified, created, removed), case 3) will has issue which is showed in the example code above.
With the changed undo stack processing order (created, modified, removed), case 1) 2) 3) all work fine.
The case 4) is the most complicated one. You can even make the modified undo stack has two records that A and B have swapped their original value. This fix can not handle this case.