Closed LostKobrakai closed 2 years ago
I'm not sure how to set the mode for the transaction from within ecto, but the db_connection
implementation supports it
I just noticed this just works: Edith.Repo.transaction(…, mode: :immediate)
:)
I didn't realize that transaction/2
took that as an option. It isn't documented AFAIK.
Yeah, things passed through to drivers are not the best documented thing in ecto.
Perhaps a PR to upstream ecto would be welcome about passing the mode. I believe postgres and mysql implementations support the mode:
directive.
I've a usecase for a read-then-update flow and I was considering using an immediate transaction to prevent the race condition of a concurrent transaction changing the db after the initial read, but before updates were written. I saw exqlite has some code around those, but I'm wondering if that can be exposed to ecto based transactions.