Closed dorongutman closed 6 years ago
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 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 ?
@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:
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
flush($document)
in 2.0 - the correct solution is to use change tracking policies.
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.