aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation/query_methods.rb
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2010-07-30 02:35:24 +0200
committerXavier Noria <fxn@hashref.com>2010-07-30 02:35:24 +0200
commitccd45618ed9a629c9535a5ff84ef5c238befa4ab (patch)
tree0a582bf695dce01240762d2b8516efde43bc3515 /activerecord/lib/active_record/relation/query_methods.rb
parent3c3ff1377d17b584dd14d85c7cecab59ddff2679 (diff)
parent755af497555fde16db86f7e51f6462b0aca79b49 (diff)
downloadrails-ccd45618ed9a629c9535a5ff84ef5c238befa4ab.tar.gz
rails-ccd45618ed9a629c9535a5ff84ef5c238befa4ab.tar.bz2
rails-ccd45618ed9a629c9535a5ff84ef5c238befa4ab.zip
Merge remote branch 'rails/master'
Diffstat (limited to 'activerecord/lib/active_record/relation/query_methods.rb')
-rw-r--r--activerecord/lib/active_record/relation/query_methods.rb13
1 files changed, 5 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb
index 0593897fa5..716e7275a5 100644
--- a/activerecord/lib/active_record/relation/query_methods.rb
+++ b/activerecord/lib/active_record/relation/query_methods.rb
@@ -47,9 +47,9 @@ module ActiveRecord
clone.tap {|r| r.joins_values += args if args.present? }
end
- def where(*args)
- value = build_where(*args)
- clone.tap {|r| r.where_values += Array.wrap(value) if value.present? }
+ def where(opts, other = nil)
+ value = build_where(opts, other)
+ value ? clone.tap {|r| r.where_values += Array.wrap(value) } : clone
end
def having(*args)
@@ -166,13 +166,10 @@ module ActiveRecord
arel
end
- def build_where(*args)
- return if args.blank?
-
- opts = args.first
+ def build_where(opts, other = nil)
case opts
when String, Array
- @klass.send(:sanitize_sql, args.size > 1 ? args : opts)
+ @klass.send(:sanitize_sql, other ? [opts, other] : opts)
when Hash
attributes = @klass.send(:expand_hash_conditions_for_aggregates, opts)
PredicateBuilder.new(table.engine).build_from_hash(attributes, table)