diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2010-01-04 02:05:18 +0530 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2010-01-04 02:05:18 +0530 |
commit | a115b5d79a850bb56cd3c9db9a05d6da35e3d7be (patch) | |
tree | 858358fff64c6abde6838297ba5ad0d7e65db006 /activerecord/lib/active_record | |
parent | 4796be33a464a4587d0e22dfef113aca597c91c4 (diff) | |
download | rails-a115b5d79a850bb56cd3c9db9a05d6da35e3d7be.tar.gz rails-a115b5d79a850bb56cd3c9db9a05d6da35e3d7be.tar.bz2 rails-a115b5d79a850bb56cd3c9db9a05d6da35e3d7be.zip |
Ensure using proper engine for Arel::Table
Diffstat (limited to 'activerecord/lib/active_record')
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 10 | ||||
-rw-r--r-- | activerecord/lib/active_record/relation.rb | 2 |
2 files changed, 9 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 70776c7aa2..ec7725d256 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1510,11 +1510,17 @@ module ActiveRecord #:nodoc: end def active_relation_table(table_name_alias = nil) - Arel::Table.new(table_name, :as => table_name_alias) + Arel::Table.new(table_name, :as => table_name_alias, :engine => active_relation_engine) end def active_relation_engine - @active_relation_engine ||= Arel::Sql::Engine.new(self) + @active_relation_engine ||= begin + if self == ActiveRecord::Base + Arel::Table.engine + else + connection_handler.connection_pools[name] ? Arel::Sql::Engine.new(self) : superclass.active_relation_engine + end + end end private diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index ec8ae21726..6b9925d4e7 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -130,7 +130,7 @@ module ActiveRecord end def table - @table ||= Arel::Table.new(@klass.table_name, Arel::Sql::Engine.new(@klass)) + @table ||= Arel::Table.new(@klass.table_name, :engine => @klass.active_relation_engine) end def primary_key |