aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-09-21 13:53:21 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-09-21 13:53:47 -0700
commit96bd936b64ae06d4c38e8de862521e22d7c809b9 (patch)
treebb31dbdbe9a64c13ada149c1c28e3b8a696df5b5 /activerecord/lib/active_record/associations.rb
parentf4abe66d35662064c4b3634fc0691a27a4ee4253 (diff)
downloadrails-96bd936b64ae06d4c38e8de862521e22d7c809b9.tar.gz
rails-96bd936b64ae06d4c38e8de862521e22d7c809b9.tar.bz2
rails-96bd936b64ae06d4c38e8de862521e22d7c809b9.zip
providing arel with column information when possible [#5392 state:resolved]
Diffstat (limited to 'activerecord/lib/active_record/associations.rb')
-rw-r--r--activerecord/lib/active_record/associations.rb13
1 files changed, 10 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb
index 4bf206d589..acfc5ccf14 100644
--- a/activerecord/lib/active_record/associations.rb
+++ b/activerecord/lib/active_record/associations.rb
@@ -2107,8 +2107,13 @@ module ActiveRecord
def association_join
return @join if @join
- aliased_table = Arel::Table.new(table_name, :as => @aliased_table_name, :engine => arel_engine)
- parent_table = Arel::Table.new(parent.table_name, :as => parent.aliased_table_name, :engine => arel_engine)
+ aliased_table = Arel::Table.new(table_name, :as => @aliased_table_name,
+ :engine => arel_engine,
+ :columns => klass.columns)
+
+ parent_table = Arel::Table.new(parent.table_name, :as => parent.aliased_table_name,
+ :engine => arel_engine,
+ :columns => parent.active_record.columns)
@join = case reflection.macro
when :has_and_belongs_to_many
@@ -2191,7 +2196,9 @@ module ActiveRecord
end
def relation
- aliased = Arel::Table.new(table_name, :as => @aliased_table_name, :engine => arel_engine)
+ aliased = Arel::Table.new(table_name, :as => @aliased_table_name,
+ :engine => arel_engine,
+ :columns => klass.columns)
if reflection.macro == :has_and_belongs_to_many
[Arel::Table.new(options[:join_table], :as => aliased_join_table_name, :engine => arel_engine), aliased]