diff options
author | brainopia <brainopia@evilmartians.com> | 2015-01-07 03:29:26 +0300 |
---|---|---|
committer | brainopia <brainopia@evilmartians.com> | 2015-01-08 01:42:33 +0300 |
commit | 824862807be47bee5adbd15e365a2add57df5301 (patch) | |
tree | 98bf41e7d60020a7564787fdf6e82f80e829772f /activerecord/test | |
parent | 5d28c6b5b8407abf9274f78502d387c98f209286 (diff) | |
download | rails-824862807be47bee5adbd15e365a2add57df5301.tar.gz rails-824862807be47bee5adbd15e365a2add57df5301.tar.bz2 rails-824862807be47bee5adbd15e365a2add57df5301.zip |
Fix count on a separate connection (fixes #18359)
Previosly count and other AR calculations would convert
column_name_for_operation to sql on a default Arel::Table.engine
(AR::Base) connection. That could lead to trouble if current
model has a connection to a different adapter or Base connection
is inaccessible.
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/multiple_db_test.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/activerecord/test/cases/multiple_db_test.rb b/activerecord/test/cases/multiple_db_test.rb index 3831de6ae3..15c60d5562 100644 --- a/activerecord/test/cases/multiple_db_test.rb +++ b/activerecord/test/cases/multiple_db_test.rb @@ -93,6 +93,13 @@ class MultipleDbTest < ActiveRecord::TestCase assert_not_equal Entrant.arel_engine.connection, Course.arel_engine.connection end + def test_count_on_custom_connection + ActiveRecord::Base.remove_connection + assert_equal 1, College.count + ensure + ActiveRecord::Base.establish_connection :arunit + end + unless in_memory_db? def test_associations_should_work_when_model_has_no_connection begin |