Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 8270

Show
Ignore:
Timestamp:
12/05/07 02:30:30 (5 months ago)
Author:
david
Message:

Fix that options[:from] table names should never be quoted [DHH]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activerecord/lib/active_record/associations.rb

    r8126 r8270  
    12481248        def construct_finder_sql_with_included_associations(options, join_dependency) 
    12491249          scope = scope(:find) 
    1250           sql = "SELECT #{column_aliases(join_dependency)} FROM #{connection.quote_table_name((scope && scope[:from]) || options[:from] || table_name)} " 
     1250          sql = "SELECT #{column_aliases(join_dependency)} FROM #{(scope && scope[:from]) || options[:from] || quoted_table_name} " 
    12511251          sql << join_dependency.join_associations.collect{|join| join.association_join }.join 
    12521252  
  • trunk/activerecord/test/associations/eager_test.rb

    r8036 r8270  
    3636      assert_equal posts(post), list[index] 
    3737    end 
     38  end 
     39 
     40  def test_with_two_tables_in_from_without_getting_double_quoted 
     41    posts = Post.find(:all, 
     42      :select     => "posts.*", 
     43      :from       => "posts, authors", 
     44      :include    => :comments, 
     45      :conditions => "posts.author_id = authors.id" 
     46    ) 
     47 
     48    assert_equal 2, posts.first.comments.size 
    3849  end 
    3950