diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2019-02-01 13:41:44 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-01 13:41:44 -0500 |
commit | bc0cad0690ab2c16fefae7421a2908052ca57f19 (patch) | |
tree | cd13433a1e7ce141b4d14b66cf76019686d94931 | |
parent | 630a343f739a1ba29cf93dc149fff6e3e0a00b05 (diff) | |
parent | 74dbce0fcad322ae958abc0a1e00e78a519710a1 (diff) | |
download | rails-bc0cad0690ab2c16fefae7421a2908052ca57f19.tar.gz rails-bc0cad0690ab2c16fefae7421a2908052ca57f19.tar.bz2 rails-bc0cad0690ab2c16fefae7421a2908052ca57f19.zip |
Merge pull request #35082 from Shopify/eagerly-materialize-test-transactions
Eagerly materialize the fixtures transaction
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/transaction.rb | 7 | ||||
-rw-r--r-- | activerecord/lib/active_record/test_fixtures.rb | 4 | ||||
-rw-r--r-- | activerecord/test/cases/fixtures_test.rb | 2 |
3 files changed, 8 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/transaction.rb b/activerecord/lib/active_record/connection_adapters/abstract/transaction.rb index 112f376d0a..c9e84e48cc 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/transaction.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/transaction.rb @@ -205,9 +205,12 @@ module ActiveRecord 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 diff --git a/activerecord/lib/active_record/test_fixtures.rb b/activerecord/lib/active_record/test_fixtures.rb index d29fc9f84b..8c60d71669 100644 --- a/activerecord/lib/active_record/test_fixtures.rb +++ b/activerecord/lib/active_record/test_fixtures.rb @@ -122,7 +122,7 @@ module ActiveRecord # 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 @@ -138,7 +138,7 @@ module ActiveRecord 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 diff --git a/activerecord/test/cases/fixtures_test.rb b/activerecord/test/cases/fixtures_test.rb index 2fe4879fe6..b4f28fbfd6 100644 --- a/activerecord/test/cases/fixtures_test.rb +++ b/activerecord/test/cases/fixtures_test.rb @@ -924,7 +924,7 @@ class TransactionalFixturesOnConnectionNotification < ActiveRecord::TestCase 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 |