-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add Repo.transaction_with/2 #4577
base: master
Are you sure you want to change the base?
Conversation
I'm grateful to see this being brought into Ecto ❤️ it'll help with onboarding new engineers to have I'd really like to encourage using
Regardless of how it ends up named, thanks for bringing it in! |
Thanks for bring this to Ecto ❤️ Any thoughts about also supporting returning plain |
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.
Love this!
Should probably be made an optional callback (like transaction is).
Co-authored-by: Matt Enlow <enlow@adobe.com>
Very happy to see this, been using Sasa's version for some time. Strongly against proposed function name, tho. Since one of the benefits is simpler and more readable code (with less LOC) - |
100% to this comment. I will definitely rename it to |
That's fine, but if the function signature is different than the one you expect, what will you do? IE as it stands the anonymous function is required to return EDIT: Quite a bikeshed moment. |
FWIW as the original author of the name I think that ideally, the current |
Unless Ecto v4? Could ship with a re-writer task, though perhaps I'm oversimplifying this. |
I have discussed this with @wojtekmach:
|
References:
I believe the interface and implementation are fairly uncontroversial and straightforward. I think the bigger undertaking is potentially revamping the docs, de-emphasizing Multi in favor of this, given that in a lot of (if not the vast majority of) cases, it achieves the same outcomes with less and simpler code. There are no plans to deprecate Multi.
The name of this function is not ideal, some other options considered were
Repo.transact
andRepo.with_transaction
. I thinkRepo.transaction_with
wins because basically:That is, it will show up alongside
transaction
in docs, autocomplete, etc.