summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorEtienne Massip <etienne.massip@gmail.com>2011-10-18 17:51:21 +0000
committerEtienne Massip <etienne.massip@gmail.com>2011-10-18 17:51:21 +0000
commit33f65c5a48451f481d592239e6fe1b6c89596b03 (patch)
treef275eb83ff5cd00282f6b343b0fb46a40d6331e4 /app
parent78a875784620eb6eecddacce8f9fdc7742cc1f09 (diff)
downloadredmine-33f65c5a48451f481d592239e6fe1b6c89596b03.tar.gz
redmine-33f65c5a48451f481d592239e6fe1b6c89596b03.zip
Filter out illegal values to prevent raise of PostgreSQL exceptions, restored last test part removed with r7625 (#8371).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7628 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/models/query.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/app/models/query.rb b/app/models/query.rb
index 9eac4b81c..411bef19f 100644
--- a/app/models/query.rb
+++ b/app/models/query.rb
@@ -333,6 +333,10 @@ class Query < ActiveRecord::Base
available_filters[field][:type] if available_filters.has_key?(field)
end
+ def allowed_values_for(field)
+ available_filters[field][:values] if available_filters.has_key?(field)
+ end
+
def operator_for(field)
has_filter?(field) ? filters[field][:operator] : nil
end
@@ -649,6 +653,7 @@ class Query < ActiveRecord::Base
sql = ''
case operator
when "="
+ value &= allowed_values_for(field).collect {|val| val[1]} if value.present? && allowed_values_for(field).present?
if value.any?
case type_for(field)
when :date, :date_past
@@ -665,6 +670,7 @@ class Query < ActiveRecord::Base
sql = "1=0"
end
when "!"
+ value &= allowed_values_for(field).collect {|val| val[1]} if value.present? && allowed_values_for(field).present?
if value.any?
sql = "(#{db_table}.#{db_field} IS NULL OR #{db_table}.#{db_field} NOT IN (" + value.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + "))"
else