Permalink
Browse files

Base.merge_conditions is no longer needed

  • Loading branch information...
lifo committed Jan 20, 2010
1 parent 909443e commit 1fb78e3ed8142782f19877a195f10b1828dd672c
Showing with 2 additions and 16 deletions.
  1. +0 −14 activerecord/lib/active_record/base.rb
  2. +2 −2 activerecord/lib/active_record/relation/query_methods.rb
@@ -1238,20 +1238,6 @@ def sti_name
store_full_sti_class ? name : name.demodulize
end
- # Merges conditions so that the result is a valid +condition+
- def merge_conditions(*conditions)
- segments = []
-
- conditions.each do |condition|
- unless condition.blank?
- sql = sanitize_sql(condition)
- segments << sql unless sql.blank?
- end
- end
-
- "(#{segments.join(') AND (')})" unless segments.empty?
- end
-
def unscoped
@unscoped ||= Relation.new(self, arel_table)
finder_needs_type_condition? ? @unscoped.where(type_condition) : @unscoped
@@ -167,8 +167,8 @@ def build_where(*args)
builder = PredicateBuilder.new(table.engine)
conditions = if [String, Array].include?(args.first.class)
- merged = @klass.send(:merge_conditions, args.size > 1 ? Array.wrap(args) : args.first)
- Arel::SqlLiteral.new(merged) if merged
+ sql = @klass.send(:sanitize_sql, args.size > 1 ? args : args.first)
+ Arel::SqlLiteral.new("(#{sql})") if sql.present?
elsif args.first.is_a?(Hash)
attributes = @klass.send(:expand_hash_conditions_for_aggregates, args.first)
builder.build_from_hash(attributes, table)

0 comments on commit 1fb78e3

Please sign in to comment.