diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2011-07-18 17:27:21 -0700 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2011-07-18 17:27:21 -0700 |
commit | 73efb68dc9cbecaad81598d6653cb3bb1927a40d (patch) | |
tree | b390cfb5098813eefb1fc6034ffca73c6aa42b44 | |
parent | aaff90ac7f4d7d796c0a420f660dc11fd4791f51 (diff) | |
parent | 0e1d617b8b869426960ec25b62620fe1599cb5e6 (diff) | |
download | rails-73efb68dc9cbecaad81598d6653cb3bb1927a40d.tar.gz rails-73efb68dc9cbecaad81598d6653cb3bb1927a40d.tar.bz2 rails-73efb68dc9cbecaad81598d6653cb3bb1927a40d.zip |
Merge pull request #2139 from mcmire/issue_2078_master
Fix for #2078 (against master)
-rw-r--r-- | activerecord/lib/active_record/relation/finder_methods.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/associations/eager_test.rb | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb index 283115a448..220ead4edb 100644 --- a/activerecord/lib/active_record/relation/finder_methods.rb +++ b/activerecord/lib/active_record/relation/finder_methods.rb @@ -243,7 +243,7 @@ module ActiveRecord end def construct_limited_ids_condition(relation) - orders = relation.order_values + orders = relation.order_values.map(&:presence).compact values = @klass.connection.distinct("#{@klass.connection.quote_table_name table_name}.#{primary_key}", orders) relation = relation.dup diff --git a/activerecord/test/cases/associations/eager_test.rb b/activerecord/test/cases/associations/eager_test.rb index f1d061133c..c6e451fc57 100644 --- a/activerecord/test/cases/associations/eager_test.rb +++ b/activerecord/test/cases/associations/eager_test.rb @@ -1048,4 +1048,16 @@ class EagerAssociationTest < ActiveRecord::TestCase assert_not_equal 0, post.comments.to_a.count end end + + def test_join_eager_with_empty_order_should_generate_valid_sql + assert_nothing_raised(ActiveRecord::StatementInvalid) do + Post.includes(:comments).order("").where(:comments => {:body => "Thank you for the welcome"}).first + end + end + + def test_join_eager_with_nil_order_should_generate_valid_sql + assert_nothing_raised(ActiveRecord::StatementInvalid) do + Post.includes(:comments).order(nil).where(:comments => {:body => "Thank you for the welcome"}).first + end + end end |