Skip to content

Commit

Permalink
Note that Repo.in_transaction?/0 doesn't reflect per-test transactions (
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanl authored and josevalim committed Jun 25, 2018
1 parent 1f4891d commit 7b51429
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/ecto/repo.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 1055,15 @@ defmodule Ecto.Repo do
@doc """
Returns true if the current process is inside a transaction.
If you are using the `Ecto.Adapters.SQL.Sandbox` in tests, note that even
though each test is inside a transaction, `in_transaction?/0` will only
return true inside transactions explicitly created with `transaction/2`. This
is done so the test environment mimics dev and prod.
If you are trying to debug transaction-related code while using
`Ecto.Adapters.SQL.Sandbox`, it may be more helpful to configure the database
to log all statements and consult those logs.
## Examples
MyRepo.in_transaction?
Expand Down

0 comments on commit 7b51429

Please sign in to comment.