From 956437b7fe597816c0158beb7187ad826e7085fd Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Fri, 5 Dec 2008 22:56:13 +0000 Subject: [PATCH] Final refactoring on Query#sql_for_field to rename v to value git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2092 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/query.rb | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/app/models/query.rb b/app/models/query.rb index b5d6afc6b..1a4845975 100644 --- a/app/models/query.rb +++ b/app/models/query.rb @@ -320,14 +320,14 @@ class Query < ActiveRecord::Base private - # Helper method to generate the WHERE sql for a +field+ with a value (+v+) - def sql_for_field(field, v, db_table, db_field, is_custom_filter) + # Helper method to generate the WHERE sql for a +field+ with a +value+ + def sql_for_field(field, value, db_table, db_field, is_custom_filter) sql = '' case operator_for field when "=" - sql = "#{db_table}.#{db_field} IN (" + v.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + ")" + sql = "#{db_table}.#{db_field} IN (" + value.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + ")" when "!" - sql = "(#{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 (" + value.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 @@ -335,25 +335,25 @@ class Query < ActiveRecord::Base sql = "#{db_table}.#{db_field} IS NOT NULL" sql << " AND #{db_table}.#{db_field} <> ''" if is_custom_filter when ">=" - sql = "#{db_table}.#{db_field} >= #{v.first.to_i}" + sql = "#{db_table}.#{db_field} >= #{value.first.to_i}" when "<=" - sql = "#{db_table}.#{db_field} <= #{v.first.to_i}" + sql = "#{db_table}.#{db_field} <= #{value.first.to_i}" when "o" sql = "#{IssueStatus.table_name}.is_closed=#{connection.quoted_false}" if field == "status_id" when "c" sql = "#{IssueStatus.table_name}.is_closed=#{connection.quoted_true}" if field == "status_id" when ">t-" - sql = date_range_clause(db_table, db_field, - v.first.to_i, 0) + sql = date_range_clause(db_table, db_field, - value.first.to_i, 0) when "t+" - sql = date_range_clause(db_table, db_field, v.first.to_i, nil) + sql = date_range_clause(db_table, db_field, value.first.to_i, nil) when "