Skip to content

Commit

Permalink
Don't even try to set transaction isolation in Rails 7.1 if a transac…
Browse files Browse the repository at this point in the history
…tion is already open
  • Loading branch information
Dantemss committed Mar 11, 2024
1 parent b510baf commit fdc8fd5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/lev/routine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,14 @@ def runner=(runner)
def in_transaction(options={})
if transaction_run_by?(self)
isolation_symbol = self.class.transaction_isolation.symbol
if ActiveRecord::VERSION::MAJOR >= 4
if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1 &&
ActiveRecord::Base.connection.transaction_open?
# Don't even try to set transaction isolation if the transaction is already open
ActiveRecord::Base.transaction do
yield
raise ActiveRecord::Rollback if errors?
end
elsif ActiveRecord::VERSION::MAJOR >= 4
begin
ActiveRecord::Base.transaction(isolation: isolation_symbol) do
yield
Expand Down

0 comments on commit fdc8fd5

Please sign in to comment.