Skip to content
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

Check if embedded document is not part of atomic set query #1142

Closed
wants to merge 9 commits into from

Conversation

malarzm
Copy link
Member

@malarzm malarzm commented Jun 13, 2015

Closes #1141 (@blockjon's test is included in this PR)

For the record it was working for set strategy but there were 2 queries issued - first to update chapters.0.status from DocumentPersister and later to update whole chapters collection from CollectionPersister. I think it's worth fixing, but I've ran into some problems and decided it's outside of scope of this PR.

… "Cannot update 'chapters.0.status' and 'chapters' at the same time'".
@malarzm malarzm added the Bug label Jun 13, 2015
@malarzm malarzm added this to the 1.0.0 milestone Jun 13, 2015
@@ -485,4 +485,13 @@ private function isScheduledForInsert($document)
return $this->uow->isScheduledForInsert($document)
|| $this->uow->getDocumentPersister(get_class($document))->isQueuedForInsert($document);
}

private function isPartOfAtomicUpdate($embeddeDoc)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're also calculating this in the DocumentPersister::getAtomicCollectionUpdateQuery(), perhaps it makes sense to move this to a public UnitOfWork method (annotated with @internal)? Something like isWithinAtomicCollection() with an $embeddedDocument argument seems descriptive enough.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering about that but in DocumentPersister::getAtomicCollectionUpdateQuery() we want to get mapping back while here true/false is enough and I don't think bool|array is good idea for is-ser. Maybe method like getTopmostCollectionMapping returning array|null would be better? Sometimes I hate naming things

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good point about requiring the mapping. Let's skip this for now, and optionally leave a // TODO: ... comment in place to refactor it later.

@blockjon
Copy link

So for the first time, all of my unit and integration tests have passed.That's very exciting as I have been trying for a long time to fix our data corruption problems. I will try this on my canary server this week and see if things actually work correctly but it appears that I'm in really good shape.

@malarzm
Copy link
Member Author

malarzm commented Jun 13, 2015

@blockjon awesome 👍

See logic in UnitOfWork::persistNew().
Restructures the nullable handling and adds an early continue statement. Additionally, limit reference-one handling to owning sides, which is consistent with prepareUpdateData() and prepareUpsertData().
Remove a level of indentation for the embed-many branch by moving the $new check to the main conditional.
Embedded documents were never scheduled for upsert, so they would only be inserted at this point. The embed-many condition for prepareUpsertData() should be identical to what we already do in prepareInsertData(), so we can add an early continue statement and eliminate the later conditionals.
This addresses an earlier hypothesis that embedded documents are never scheduled for upsert (due to logic in UnitOfWork::persistNew()).
Additional fixes PersistenceBuilder handling of embedded docs
@jmikola
Copy link
Member

jmikola commented Jun 13, 2015

LGTM 👍

malarzm added a commit that referenced this pull request Jun 13, 2015
@malarzm
Copy link
Member Author

malarzm commented Jun 13, 2015

Merged manually in 10cd916

@malarzm malarzm closed this Jun 13, 2015
@malarzm malarzm deleted the gh1141 branch December 14, 2015 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants