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

Can't flush only specific documents #1149

Closed
dorongutman opened this issue Jun 15, 2015 · 4 comments
Closed

Can't flush only specific documents #1149

dorongutman opened this issue Jun 15, 2015 · 4 comments
Labels

Comments

@dorongutman
Copy link

I'm trying to call flush([$documentOne, $documentThree]) so it'll only flush these two documents and not others which I have not specified.

However, the ODM flushes all the documents that are pending.
Specifically, it flushes a scheduled "insert" which is a new document that's not referenced by any other document.

@malarzm malarzm added the Bug label Jun 15, 2015
@malarzm malarzm added this to the 1.0.0 milestone Jun 15, 2015
@malarzm
Copy link
Member

malarzm commented Jul 15, 2015

After some internal discussion it turned out that flush() with documents specified (or entities in ORM's case, where behaviour is the same) was not really meant to be "we will save just these and nothing else" restriction. This is documented here but I think it could be exposed better than on UoW's private method :)

@malarzm malarzm added Idea and removed Bug labels Jul 15, 2015
@malarzm malarzm removed this from the 1.0.0 milestone Jul 15, 2015
@dorongutman
Copy link
Author

@malarzm oh wow, that's very much confusing.. http://doctrine-mongodb-odm.readthedocs.org/en/latest/reference/working-with-objects.html#flushing-single-documents

Anyways - is there any way of flushing only a single document ? Maybe with the querybuilder or something ?

@malarzm
Copy link
Member

malarzm commented Jul 16, 2015

@dorongutman heh yes, you're right, we need to write a disclaimer there as well... To be honest I was a bit surprised as well, but this predates my work here very much ;) Anyway right now I see two possible ways:

  1. As you suggest QueryBuilder might be the way to go (but there will be no events and preparation)
  2. Change your flow to not schedule unwanted documents or detach them first

Also there's a chance we may diverge from ORM here and actually allow flushing only specified documents. One of main obstacles would be that current commit saves all collections BUT #1155 changes that to update collections only when their owner is updated (so outstanding things will be orphan removal and updating UoW internal state). I've marked this yesterday as an idea to allow discussion whether we want to introduce the change or not

@alcaeus
Copy link
Member

alcaeus commented Dec 22, 2017

#1707 tracks the removal of flush($document) in 2.0 - the correct solution is to use change tracking policies.

@alcaeus alcaeus closed this as completed Dec 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants