aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-12-07 14:47:21 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2010-12-07 14:47:21 -0800
commitef79658bd143a9243eefa90db2f9ce300f18dd0d (patch)
tree3eb308220e1809b0a6860828f5a26b28f8cd1ac1
parent70ab4502749d23464f06d50779aeea0b3275d67c (diff)
downloadrails-ef79658bd143a9243eefa90db2f9ce300f18dd0d.tar.gz
rails-ef79658bd143a9243eefa90db2f9ce300f18dd0d.tar.bz2
rails-ef79658bd143a9243eefa90db2f9ce300f18dd0d.zip
save the AR reference rather than delegating
-rw-r--r--activerecord/lib/active_record/associations/class_methods/join_dependency.rb9
1 files changed, 5 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/associations/class_methods/join_dependency.rb b/activerecord/lib/active_record/associations/class_methods/join_dependency.rb
index c578845878..9f171f891d 100644
--- a/activerecord/lib/active_record/associations/class_methods/join_dependency.rb
+++ b/activerecord/lib/active_record/associations/class_methods/join_dependency.rb
@@ -6,9 +6,10 @@ module ActiveRecord
module Associations
module ClassMethods
class JoinDependency # :nodoc:
- attr_reader :join_parts, :reflections, :table_aliases
+ attr_reader :join_parts, :reflections, :table_aliases, :active_record
def initialize(base, associations, joins)
+ @active_record = base
@table_joins = joins || ''
@join_parts = [JoinBase.new(base)]
@associations = {}
@@ -45,7 +46,7 @@ module ActiveRecord
def count_aliases_from_table_joins(name)
# quoted_name should be downcased as some database adapters (Oracle) return quoted name in uppercase
- quoted_name = join_base.active_record.connection.quote_table_name(name.downcase).downcase
+ quoted_name = active_record.connection.quote_table_name(name.downcase).downcase
join_sql = @table_joins.downcase
join_sql.blank? ? 0 :
# Table names
@@ -61,11 +62,11 @@ module ActiveRecord
records = rows.map { |model|
primary_id = model[primary_key]
parent = parents[primary_id] ||= join_base.instantiate(model)
- construct(parent, @associations, join_associations.dup, model)
+ construct(parent, @associations, join_associations, model)
parent
}.uniq
- remove_duplicate_results!(join_base.active_record, records, @associations)
+ remove_duplicate_results!(active_record, records, @associations)
records
end