diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2010-01-03 03:56:21 +0530 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2010-01-03 03:56:21 +0530 |
commit | e9ebf8b898e0dba4ca62cca7eb26987a9117a20e (patch) | |
tree | 1ebac13700163c953052a8506c2c5079480dcb3c /activerecord/lib | |
parent | 0d1a2a3c2239ed02f39e3e4690b905b0e86e80be (diff) | |
download | rails-e9ebf8b898e0dba4ca62cca7eb26987a9117a20e.tar.gz rails-e9ebf8b898e0dba4ca62cca7eb26987a9117a20e.tar.bz2 rails-e9ebf8b898e0dba4ca62cca7eb26987a9117a20e.zip |
Cache Relation#to_sql
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/relation.rb | 7 |
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) |