-
Notifications
You must be signed in to change notification settings - Fork 227
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
Use session in document insert #1018
Use session in document insert #1018
Conversation
4c17e6c
to
280e92c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Thank you for your contribution. Looks good to me.
@adeelsohailahmed Hi! Is there a way to expedite the process? Can we ping other collaborators to review? |
Beyond requesting a review from the team (which I've already done), I don't think there's much we can do. |
That’s perfect! Thank you 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Nice! Thank you! Can somebody merge it? |
Summary
This PR fixes a transactional integrity issue in Beanie by ensuring that document saves are correctly associated with the current transaction session.
Problem
When saving documents within a transaction using Beanie, a bug causes linked documents to be saved outside the transaction context if the session parameter is not explicitly provided. This behavior can lead to partial updates where some documents are persisted even if the transaction fails, undermining the purpose of using transactions.
Solution
The change explicitly adds
session=session
to thesave
function for documents within a transaction. This ensures that all document saves are bound to the active transaction, preventing unintended persistence of documents if the transaction is rolled back.This fix maintains the atomicity of transactions by ensuring all operations are executed within the transaction context, thus preserving data consistency and integrity.