Skip to content

Commit e38f9dd

Browse files
authored
Add Ecto.ConstraintError to Repo.delete/2 docs (#3757)
1 parent b20d814 commit e38f9dd

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/ecto/repo.ex

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,14 +1621,16 @@ defmodule Ecto.Repo do
16211621
Deletes a struct using its primary key.
16221622
16231623
If the struct has no primary key, `Ecto.NoPrimaryKeyFieldError`
1624-
will be raised. If the struct has been removed from db prior to
1625-
call, `Ecto.StaleEntryError` will be raised. If more than one
1626-
database operation is required, they're automatically wrapped
1627-
in a transaction.
1624+
will be raised. If the struct has been removed prior to the call,
1625+
`Ecto.StaleEntryError` will be raised. If more than one database
1626+
operation is required, they're automatically wrapped in a transaction.
16281627
16291628
It returns `{:ok, struct}` if the struct has been successfully
16301629
deleted or `{:error, changeset}` if there was a validation
1631-
or a known constraint error.
1630+
or a known constraint error. By default, constraint errors will
1631+
raise the `Ecto.ConstraintError` exception, unless a changeset is
1632+
given as the first argument with the relevant constraints declared
1633+
in it (see `Ecto.Changeset`).
16321634
16331635
## Options
16341636

0 commit comments

Comments
 (0)