aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/relation.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb
index c828c0b751..31c7acf346 100644
--- a/activerecord/lib/active_record/relation.rb
+++ b/activerecord/lib/active_record/relation.rb
@@ -2,7 +2,6 @@ module ActiveRecord
class Relation
include QueryMethods, FinderMethods, CalculationMethods
- delegate :to_sql, :to => :relation
delegate :length, :collect, :map, :each, :all?, :to => :to_a
attr_reader :relation, :klass
@@ -157,7 +156,7 @@ module ActiveRecord
end
def reset
- @first = @last = @create_scope = @joined_tables = nil
+ @first = @last = @create_scope = @joined_tables = @to_sql = nil
@records = []
self
end
@@ -180,6 +179,10 @@ module ActiveRecord
@primary_key ||= table[@klass.primary_key]
end
+ def to_sql
+ @to_sql ||= @relation.to_sql
+ end
+
protected
def method_missing(method, *args, &block)