diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-07-28 17:01:19 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-07-28 17:01:32 -0700 |
commit | 1c030a3c3c61d6d6262785bf67e1d8f44da87ea5 (patch) | |
tree | 6cb32d44b3743d92aac795d293a29e696f38927c /activerecord/lib/active_record | |
parent | 4952a80200cf916636b1e0ca11985bbd09f42a80 (diff) | |
download | rails-1c030a3c3c61d6d6262785bf67e1d8f44da87ea5.tar.gz rails-1c030a3c3c61d6d6262785bf67e1d8f44da87ea5.tar.bz2 rails-1c030a3c3c61d6d6262785bf67e1d8f44da87ea5.zip |
avoid calling to_sql twice
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/relation/query_methods.rb | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index 0593897fa5..cba22c2207 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -135,11 +135,14 @@ module ActiveRecord next if where.blank? case where - when Arel::SqlLiteral - arel = arel.where(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})")) else - sql = where.is_a?(String) ? where : where.to_sql - arel = arel.where(Arel::SqlLiteral.new("(#{sql})")) + arel = arel.where where end end |