Browse files

Revert "fix to_sql output on eager loaded relations"

This reverts commit a9748da.
  • Loading branch information...
1 parent a9748da commit d397a11ad72a6c8b35fc01917af5986cba2b4a37 @tenderlove tenderlove committed Jul 2, 2013
Showing with 1 addition and 17 deletions.
  1. +1 −9 activerecord/lib/active_record/relation.rb
  2. +0 −8 activerecord/test/cases/relations_test.rb
View
10 activerecord/lib/active_record/relation.rb
@@ -491,15 +491,7 @@ def reset
# User.where(name: 'Oscar').to_sql
# # => SELECT "users".* FROM "users" WHERE "users"."name" = 'Oscar'
def to_sql
- @to_sql ||= begin
- if eager_loading?
- join_dependency = construct_join_dependency
- relation = construct_relation_for_association_find(join_dependency)
- klass.connection.to_sql(relation.arel, relation.bind_values)
- else
- klass.connection.to_sql(arel, bind_values.dup)
- end
- end
+ @to_sql ||= klass.connection.to_sql(arel, bind_values.dup)
end
# Returns a hash of where conditions.
View
8 activerecord/test/cases/relations_test.rb
@@ -480,14 +480,6 @@ def test_loading_with_one_association
assert_equal Post.find(1).last_comment, post.last_comment
end
- def test_to_sql_on_eager_join
- expected = assert_sql {
- Post.eager_load(:last_comment).order('comments.id DESC').to_a
- }.first
- actual = Post.eager_load(:last_comment).order('comments.id DESC').to_sql
- assert_equal expected, actual
- end
-
def test_loading_with_one_association_with_non_preload
posts = Post.eager_load(:last_comment).order('comments.id DESC')
post = posts.find { |p| p.id == 1 }

0 comments on commit d397a11

Please sign in to comment.