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

$em->flush() is not supposed to effect which entities are managed #97

Open
scott-r-lindsey opened this issue Nov 9, 2015 · 3 comments

Comments

@scott-r-lindsey
Copy link

So, if I do the following:

$x = new X;
$em->persist($x); 

$em->flush();  // this updates $x in the Neo4j, as I would expect...

$x->setFoo('bar');

$em->flush(); // $x should update

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?

@lphuberdeau
Copy link
Owner

I believe this behaviour is expected.

@scott-r-lindsey scott-r-lindsey changed the title $em->flush() is not supposed to effect which persisted are managed $em->flush() is not supposed to effect which entities are managed Nov 10, 2015
@scott-r-lindsey
Copy link
Author

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?

@lphuberdeau
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants