Permalink
Browse files

Merge pull request #2140 from mcmire/issue_2078_3-1-stable

Fix for #2078 (against 3-1-stable)
  • Loading branch information...
2 parents 7deac1f + 8ebd841 commit a719ec0c2deeee33159291f00349d3be788d27fb @spastorino spastorino committed Jul 19, 2011
@@ -243,7 +243,7 @@ def apply_join_dependency(relation, join_dependency)
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
@@ -1048,4 +1048,16 @@ def test_joins_with_includes_should_preload_via_joins
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

0 comments on commit a719ec0

Please sign in to comment.