diff --git a/Gemfile.lock b/Gemfile.lock index 0cbb6b7..613dd01 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - umbrellio-utils (1.5.2) + umbrellio-utils (1.5.3) memery (~> 1) GEM diff --git a/lib/umbrellio_utils/control.rb b/lib/umbrellio_utils/control.rb index e0d833a..348dddc 100644 --- a/lib/umbrellio_utils/control.rb +++ b/lib/umbrellio_utils/control.rb @@ -19,8 +19,13 @@ def run_in_interval(interval, key:) end def retry_on_unique_violation( - times: Float::INFINITY, retry_on_all_constraints: false, checked_constraints: [], &block + times: Float::INFINITY, + retry_on_all_constraints: false, + checked_constraints: [], + &block ) + return yield if !retry_on_all_constraints && checked_constraints.empty? + retry_on(Sequel::UniqueConstraintViolation, times:) do DB.transaction(savepoint: true, &block) rescue Sequel::UniqueConstraintViolation => e diff --git a/lib/umbrellio_utils/version.rb b/lib/umbrellio_utils/version.rb index 8dcade6..63999dc 100644 --- a/lib/umbrellio_utils/version.rb +++ b/lib/umbrellio_utils/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module UmbrellioUtils - VERSION = "1.5.2" + VERSION = "1.5.3" end