Skip to content
Browse files

Shouldn't have committed this! Revert "avoid calling to_sql twice"

This reverts commit 1c030a3.
  • Loading branch information...
1 parent 1c030a3 commit d69949ed0d63ba19051a24cba992bd4655d0f5be @tenderlove tenderlove committed Jul 28, 2010
Showing with 4 additions and 7 deletions.
  1. +4 −7 activerecord/lib/active_record/relation/query_methods.rb
View
11 activerecord/lib/active_record/relation/query_methods.rb
@@ -135,14 +135,11 @@ def build_arel
next if where.blank?
case where
- when Arel::Predicates::In
- # FIXME: this needs to go away
- # when an IN is part of a larger query, the SQL seems to be different
- arel = arel.where(Arel::SqlLiteral.new("(#{where.to_sql})"))
- when String
- arel = arel.where(Arel::SqlLiteral.new("(#{where})"))
+ when Arel::SqlLiteral
+ arel = arel.where(where)
else
- arel = arel.where where
+ sql = where.is_a?(String) ? where : where.to_sql
+ arel = arel.where(Arel::SqlLiteral.new("(#{sql})"))
end
end

0 comments on commit d69949e

Please sign in to comment.
Something went wrong with that request. Please try again.