From 2f548b019a3bf23bf0686dc439964d2157dbe628 Mon Sep 17 00:00:00 2001 From: Aleksandr Lossenko Date: Tue, 1 Aug 2023 16:19:11 +0300 Subject: [PATCH] Document error behavior for Oban.insert_all/3 (#934) * Document error behavior for Oban.insert_all/3 --- lib/oban.ex | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/oban.ex b/lib/oban.ex index bbf3c5aa..dafdccc6 100644 --- a/lib/oban.ex +++ b/lib/oban.ex @@ -419,6 +419,16 @@ defmodule Oban do 1. This function always returns a list rather than a tuple of `{count, records}` 2. This function accepts a list of changesets rather than a list of maps or keyword lists + #### Error Handling and Rollbacks + + If `insert_all` encounters an issue, the function will raise an error based on your database + adapter. This behavior is valuable in conjunction with `c:Ecto.Repo.transaction/2` because it + allows for rollbacks. + + For example, an invalid changeset raises: + + `* (Ecto.InvalidChangesetError) could not perform insert because changeset is invalid.` + > #### 🌟 Unique Jobs and Batching {: .warning} > > Only the [SmartEngine](https://getoban.pro/docs/pro/smart_engine.html) in [Oban