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
Read-only EntityManager forking #2380
Comments
This could work only if you handle contexts yourself, so as a parameter of Not sure if we should throw in such case, maybe a warning + noop might be a better solution? Also not sure about disallowing |
not necessarily, java world introduces this concept via decorators as well (eg: spring's @transactional(readOnly=true). I assume that the RequestContext could have a similar option and simply fork again if the flag is true.
from what i understood, since those methods bypass the identity map, it would execute immediately vs waiting for flush?
the problem with this, is you will only know something is wrong when a flush is attempted. if a developer writes code assuming it will eventually get flushed, it could go to production without any errors if that execution path never flushes (such as depending on web requests to flush at the end). |
Nope, those are basically shortcuts for QB, would you expect to forbid also query builder? |
yep, qb would be limited to select, count, etc |
@B4nan i believe this issue is the last thing remaining to get rid of my "EntityManagerWrapper" Does simply adding a flag to |
Yeah, that should cover most of it. I am still not sure about the restrictions around QB/native* methods, so let's keep that for some other time I guess. For flushing it sounds fine - at the same time this flag should set the |
In coming up with a solution to flush less (see #2379), i realized one aspect that may help is the ability to access a read-only version of the entity manager that would effectively never flush or write to the database (and perhaps see some performance wins by reducing the about of operations ran during various API calls) and only support select queries (and perhaps throw an error if the user attempts to invoke persist or some other modifying function, though wouldn't protect from raw queries).
example, if a GraphQL request comes in for mutating, it will auto-flush, but if it is a standard query, it will return a version which prevents modifications and disable auto flushing:
The text was updated successfully, but these errors were encountered: