Restore transactions in materialized state where appropriate

We may be restoring a connection after #with_raw_connection has already
passed #materialize_transactions, so it's important we eagerly return
things to exactly the state they had before.
This commit is contained in:
Matthew Draper 2022-03-08 22:34:51 +10:30
parent 129bfa193c
commit b9f44e66ba
2 changed files with 5 additions and 4 deletions

@ -142,7 +142,10 @@ def materialized?
end
def restore!
@materialized = false
if materialized?
@materialized = false
materialize!
end
end
def rollback_records
@ -390,8 +393,6 @@ def restore_transactions
@stack.each(&:restore!)
materialize_transactions unless @lazy_transactions_enabled
true
end

@ -405,7 +405,7 @@ def setup
assert raw_transaction_open?(@connection)
@connection.reconnect!(restore_transactions: true)
assert_predicate @connection, :transaction_open?
assert_not raw_transaction_open?(@connection)
assert raw_transaction_open?(@connection)
ensure
@connection.reconnect!
assert_not_predicate @connection, :transaction_open?