From d69949ed0d63ba19051a24cba992bd4655d0f5be Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 28 Jul 2010 17:03:52 -0700 Subject: Shouldn't have committed this! Revert "avoid calling to_sql twice" This reverts commit 1c030a3c3c61d6d6262785bf67e1d8f44da87ea5. --- activerecord/lib/active_record/relation/query_methods.rb | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index cba22c2207..0593897fa5 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -135,14 +135,11 @@ module ActiveRecord 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 -- cgit v1.2.3