Skip to content

Commit a92285a

Browse files
authored
Mention automatic transaction wrapping in Repo docs (#3746)
`Repo.insert/1`, `Repo.update/2` and `Repo.delete/1` may do many database operations. When they need to do so, these are wrapped in a transaction.
1 parent 58d68ee commit a92285a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/ecto/repo.ex

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,7 +1317,8 @@ defmodule Ecto.Repo do
13171317
13181318
In case a changeset is given, the changes in the changeset are
13191319
merged with the struct fields, and all of them are sent to the
1320-
database.
1320+
database. If more than one database operation is required, they're
1321+
automatically wrapped in a transaction.
13211322
13221323
It returns `{:ok, struct}` if the struct has been successfully
13231324
inserted or `{:error, changeset}` if there was a validation
@@ -1484,7 +1485,8 @@ defmodule Ecto.Repo do
14841485
A changeset is required as it is the only mechanism for
14851486
tracking dirty changes. Only the fields present in the `changes` part
14861487
of the changeset are sent to the database. Any other, in-memory
1487-
changes done to the schema are ignored.
1488+
changes done to the schema are ignored. If more than one database
1489+
operation is required, they're automatically wrapped in a transaction.
14881490
14891491
If the struct has no primary key, `Ecto.NoPrimaryKeyFieldError`
14901492
will be raised.
@@ -1591,7 +1593,9 @@ defmodule Ecto.Repo do
15911593
15921594
If the struct has no primary key, `Ecto.NoPrimaryKeyFieldError`
15931595
will be raised. If the struct has been removed from db prior to
1594-
call, `Ecto.StaleEntryError` will be raised.
1596+
call, `Ecto.StaleEntryError` will be raised. If more than one
1597+
database operation is required, they're automatically wrapped
1598+
in a transaction.
15951599
15961600
It returns `{:ok, struct}` if the struct has been successfully
15971601
deleted or `{:error, changeset}` if there was a validation

0 commit comments

Comments
 (0)