Open scott-r-lindsey opened 9 years ago
I believe this behaviour is expected.
Well I'm looking for some explicit documentation but not really finding it! It just seems to be assumed.
I'm not going to call the behavior wrong -- It's your OGM -- but it definitely differs from Doctrine or MongoODM.
And it seems a little hard to work with. If you break your application up into lots of little components (per the Symfony way), one of them might need to write data, and it should be able to do so without un-persisting objects that the controller expects to hand to twig (because then twig will not be able to lazy-load relations).
I wonder if the fix is as simple as removing one or two lines?
Is twig really unable to lazy-load relations after a flush()?
This is all a long time ago, but from what I recall, the persist list was really just a list of things to persist on the next flush.
Feel free to experiment and see what breaks if you remove the explicit clear. I guess it could also be made optional.
So, if I do the following:
But it doesn't work unless I add another $em->persist($x) after the flush. I would expect that flush() would not effect which entities are managed, but it seems that flushing is effectively executing a clear() as a side effect.
Are my expectations out of whack or is this a bug?