Skip to content

Commit 7a9b725

Browse files
authored
Merge pull request rails#53855 from rails/rm-transaction-open
Change the internal transaction state to be closed when the transaction is finalized
2 parents 5520bd8 + 334c271 commit 7a9b725

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

activerecord/lib/active_record.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ def self.all_open_transactions # :nodoc:
550550
if active_connection = pool.active_connection
551551
current_transaction = active_connection.current_transaction
552552

553-
if current_transaction.open? && current_transaction.joinable? && !current_transaction.state.invalidated?
553+
if current_transaction.open? && current_transaction.joinable?
554554
open_transactions << current_transaction
555555
end
556556
end

activerecord/lib/active_record/connection_adapters/abstract/transaction.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,11 @@ def dirty?
175175
end
176176

177177
def open?
178-
true
178+
!closed?
179179
end
180180

181181
def closed?
182-
false
182+
@state.finalized?
183183
end
184184

185185
def add_record(record, ensure_finalize = true)

activerecord/lib/active_record/transaction.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def open?
112112

113113
# Returns true if the transaction doesn't exist or is finalized.
114114
def closed?
115-
@internal_transaction.nil? || @internal_transaction.state.finalized?
115+
@internal_transaction.nil? || @internal_transaction.closed?
116116
end
117117

118118
alias_method :blank?, :closed?

0 commit comments

Comments
 (0)