Skip to content

Check for duplicates before scheduling orphanRemoval #1278

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

Closed
wants to merge 8 commits into from

Conversation

malarzm
Copy link
Member

@malarzm malarzm commented Nov 15, 2015

Fixes #1275 and closes #1277 BUT increases complexity of set and removeElement when orphanRemoval is enabled

@alcaeus
Copy link
Member

alcaeus commented Nov 19, 2015

I took another look at the whole embedding issue and it is the same problem as with referenced documents: orphanRemoval (which is implied for embedded collections).

For referenced documents, the sorting bug (when switching two elements) manifests itself by removing the referenced document but leaving the reference in the collection (thus leading to a proxy initialization failed error).
For embedded documents however the document would not be removed directly from the database until the next changeset computation. This is why everything seems fine until after the preUpdate lifecycle callback: after the callback is invoked, changeset computation sees that the element in question was removed (documents scheduled for orphanRemoval are scheduled for removal before inserts and updates are executed) and also removes it from the collection.

Since both problems boil down to orphanRemoval, this PR effectively fixes that weird behavior as well.

@malarzm
Copy link
Member Author

malarzm commented Nov 19, 2015

How about we stop using orphanRemoval for embeds? If firing lifecycle events is relying on this we should be able to employ getDeleteDiff I believe?

@malarzm malarzm removed this from the 1.0.4 milestone Dec 14, 2015
@malarzm
Copy link
Member Author

malarzm commented Dec 14, 2015

Superseded by #1281

@malarzm malarzm closed this Dec 14, 2015
@malarzm malarzm deleted the VoycerAG-sorting_bug branch December 14, 2015 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sorting collections on 1.0.3 leads to data loss
4 participants