From 2ff73039bdb6880af5586d8e4d6960b34cdf00ce Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Wed, 21 Apr 2010 02:43:36 +0100 Subject: Build PredicateBuilder object only when needed --- activerecord/lib/active_record/relation/query_methods.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index 09332418d5..58af930446 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -187,15 +187,13 @@ module ActiveRecord def build_where(*args) return if args.blank? - builder = PredicateBuilder.new(table.engine) - opts = args.first case opts when String, Array @klass.send(:sanitize_sql, args.size > 1 ? args : opts) when Hash attributes = @klass.send(:expand_hash_conditions_for_aggregates, opts) - builder.build_from_hash(attributes, table) + PredicateBuilder.new(table.engine).build_from_hash(attributes, table) else opts end -- cgit v1.2.3