Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix for #2078 (against 3-1-stable) #2140

Merged
merged 1 commit into from

2 participants

@mcmire

No description provided.

@spastorino spastorino merged commit a719ec0 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 18, 2011
  1. @mcmire
This page is out of date. Refresh to see the latest.
View
2  activerecord/lib/active_record/relation/finder_methods.rb
@@ -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
View
12 activerecord/test/cases/associations/eager_test.rb
@@ -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
Something went wrong with that request. Please try again.