diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2010-01-03 03:58:34 +0530 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2010-01-03 03:58:34 +0530 |
commit | 47da00e94b5b35fb98add859feae1bfc47d969ec (patch) | |
tree | 6408f9b6d580d07df3a1a9b284a8220cb37b4045 /activerecord/lib | |
parent | e9ebf8b898e0dba4ca62cca7eb26987a9117a20e (diff) | |
download | rails-47da00e94b5b35fb98add859feae1bfc47d969ec.tar.gz rails-47da00e94b5b35fb98add859feae1bfc47d969ec.tar.bz2 rails-47da00e94b5b35fb98add859feae1bfc47d969ec.zip |
Further simplify Relation#references_eager_loaded_tables?
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/relation.rb | 23 |
1 files changed, 3 insertions, 20 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index 31c7acf346..114095b7ef 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -156,7 +156,7 @@ module ActiveRecord end def reset - @first = @last = @create_scope = @joined_tables = @to_sql = nil + @first = @last = @create_scope = @to_sql = nil @records = [] self end @@ -220,25 +220,8 @@ module ActiveRecord end def references_eager_loaded_tables? - include_eager_order? || include_eager_conditions? || include_eager_select? - end - - def include_eager_order? - order_clause = @relation.send(:order_clauses).join(', ') - (tables_in_string(order_clause) - joined_tables).any? - end - - def include_eager_conditions? - (tables_in_string(where_clause) - joined_tables).any? - end - - def include_eager_select? - select_clause = @relation.send(:select_clauses).join(', ') - (tables_in_string(select_clause) - joined_tables).any? - end - - def joined_tables - @joined_tables ||= (tables_in_string(@relation.joins(relation)) + [table.name, table.table_alias]).compact.uniq + joined_tables = (tables_in_string(@relation.joins(relation)) + [table.name, table.table_alias]).compact.uniq + (tables_in_string(to_sql) - joined_tables).any? end def tables_in_string(string) |