From a711cbb44e7c277c0c4506e9b98abb9fe934db39 Mon Sep 17 00:00:00 2001 From: Toshi MARUYAMA Date: Mon, 27 Jan 2014 07:21:47 +0000 Subject: back out from r12715 to r12720: #connection replacing These revisions have performance regression on Rails 3.2.16. git-svn-id: http://svn.redmine.org/redmine/trunk@12735 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/query.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'app/models/query.rb') diff --git a/app/models/query.rb b/app/models/query.rb index 135d0990a..8830cc5b6 100644 --- a/app/models/query.rb +++ b/app/models/query.rb @@ -640,7 +640,7 @@ class Query < ActiveRecord::Base sql = "#{db_table}.#{db_field} BETWEEN #{value.first.to_f - 1e-5} AND #{value.first.to_f + 1e-5}" end else - sql = "#{db_table}.#{db_field} IN (" + value.collect{|val| "'#{ActiveRecord::Base.connection.quote_string(val)}'"}.join(",") + ")" + sql = "#{db_table}.#{db_field} IN (" + value.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + ")" end else # IN an empty set @@ -648,7 +648,7 @@ class Query < ActiveRecord::Base end when "!" if value.any? - sql = "(#{db_table}.#{db_field} IS NULL OR #{db_table}.#{db_field} NOT IN (" + value.collect{|val| "'#{ActiveRecord::Base.connection.quote_string(val)}'"}.join(",") + "))" + sql = "(#{db_table}.#{db_field} IS NULL OR #{db_table}.#{db_field} NOT IN (" + value.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + "))" else # NOT IN an empty set sql = "1=1" @@ -690,9 +690,9 @@ class Query < ActiveRecord::Base end end when "o" - sql = "#{queried_table_name}.status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed=#{ActiveRecord::Base.connection.quoted_false})" if field == "status_id" + sql = "#{queried_table_name}.status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed=#{connection.quoted_false})" if field == "status_id" when "c" - sql = "#{queried_table_name}.status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed=#{ActiveRecord::Base.connection.quoted_true})" if field == "status_id" + sql = "#{queried_table_name}.status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed=#{connection.quoted_true})" if field == "status_id" when "> '%s'" % [ActiveRecord::Base.connection.quoted_date(from)]) + s << ("#{table}.#{field} > '%s'" % [connection.quoted_date(from)]) end if to if to.is_a?(Date) @@ -828,7 +828,7 @@ class Query < ActiveRecord::Base if self.class.default_timezone == :utc to = to.utc end - s << ("#{table}.#{field} <= '%s'" % [ActiveRecord::Base.connection.quoted_date(to)]) + s << ("#{table}.#{field} <= '%s'" % [connection.quoted_date(to)]) end s.join(' AND ') end -- cgit v1.2.3