From: Eric Davis Date: Fri, 5 Dec 2008 22:56:08 +0000 (+0000) Subject: Bit more refactoring on Query#sql_for_field to remove multiple returns X-Git-Tag: 0.8.0-RC1~11 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a464d26e7377999337d304b3ea9c74ea28031518;p=redmine.git Bit more refactoring on Query#sql_for_field to remove multiple returns git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2091 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/models/query.rb b/app/models/query.rb index 8b036eb57..b5d6afc6b 100644 --- a/app/models/query.rb +++ b/app/models/query.rb @@ -325,51 +325,51 @@ class Query < ActiveRecord::Base sql = '' case operator_for field when "=" - return "#{db_table}.#{db_field} IN (" + v.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + ")" + sql = "#{db_table}.#{db_field} IN (" + v.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + ")" when "!" - return "(#{db_table}.#{db_field} IS NULL OR #{db_table}.#{db_field} NOT IN (" + v.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + "))" + sql = "(#{db_table}.#{db_field} IS NULL OR #{db_table}.#{db_field} NOT IN (" + v.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + "))" when "!*" sql = "#{db_table}.#{db_field} IS NULL" sql << " OR #{db_table}.#{db_field} = ''" if is_custom_filter - return sql when "*" sql = "#{db_table}.#{db_field} IS NOT NULL" sql << " AND #{db_table}.#{db_field} <> ''" if is_custom_filter - return sql when ">=" - return "#{db_table}.#{db_field} >= #{v.first.to_i}" + sql = "#{db_table}.#{db_field} >= #{v.first.to_i}" when "<=" - return "#{db_table}.#{db_field} <= #{v.first.to_i}" + sql = "#{db_table}.#{db_field} <= #{v.first.to_i}" when "o" - return "#{IssueStatus.table_name}.is_closed=#{connection.quoted_false}" if field == "status_id" + sql = "#{IssueStatus.table_name}.is_closed=#{connection.quoted_false}" if field == "status_id" when "c" - return "#{IssueStatus.table_name}.is_closed=#{connection.quoted_true}" if field == "status_id" + sql = "#{IssueStatus.table_name}.is_closed=#{connection.quoted_true}" if field == "status_id" when ">t-" - return date_range_clause(db_table, db_field, - v.first.to_i, 0) + sql = date_range_clause(db_table, db_field, - v.first.to_i, 0) when "t+" - return date_range_clause(db_table, db_field, v.first.to_i, nil) + sql = date_range_clause(db_table, db_field, v.first.to_i, nil) when "