Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eagerly materialize the fixtures transaction #35082

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,12 @@ def begin_transaction(options = {})
run_commit_callbacks: run_commit_callbacks)
end

transaction.materialize! unless @connection.supports_lazy_transactions? && lazy_transactions_enabled?
if @connection.supports_lazy_transactions? && lazy_transactions_enabled? && options[:_lazy] != false
@has_unmaterialized_transactions = true
else
transaction.materialize!
end
@stack.push(transaction)
@has_unmaterialized_transactions = true if @connection.supports_lazy_transactions?
transaction
end
end
Expand Down
4 changes: 2 additions & 2 deletions activerecord/lib/active_record/test_fixtures.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def setup_fixtures(config = ActiveRecord::Base)
# Begin transactions for connections already established
@fixture_connections = enlist_fixture_connections
@fixture_connections.each do |connection|
connection.begin_transaction joinable: false
connection.begin_transaction joinable: false, _lazy: false
connection.pool.lock_thread = true if lock_threads
end

Expand All @@ -138,7 +138,7 @@ def setup_fixtures(config = ActiveRecord::Base)
end

if connection && !@fixture_connections.include?(connection)
connection.begin_transaction joinable: false
connection.begin_transaction joinable: false, _lazy: false
connection.pool.lock_thread = true if lock_threads
@fixture_connections << connection
end
Expand Down
2 changes: 1 addition & 1 deletion activerecord/test/cases/fixtures_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ def rollback_transaction(*args); end
def lock_thread=(lock_thread); end
end.new

assert_called_with(connection, :begin_transaction, [joinable: false]) do
assert_called_with(connection, :begin_transaction, [joinable: false, _lazy: false]) do
fire_connection_notification(connection)
end
end
Expand Down