summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2013-05-16 16:29:59 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2013-05-16 16:29:59 +0000
commit35ca8732697c4a4e8b90edede8b01d0807558361 (patch)
tree5d20c2af81102665b8b4252f4b7b997eb2a3e0a8 /app
parenta4391db7cd74f2c0ddf7bae631aa8fc36f940823 (diff)
downloadredmine-35ca8732697c4a4e8b90edede8b01d0807558361.tar.gz
redmine-35ca8732697c4a4e8b90edede8b01d0807558361.zip
Fixed that filtering may return unwanted blank values (#14051).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11850 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/models/query.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/app/models/query.rb b/app/models/query.rb
index db6ca07a5..a5e7abd4c 100644
--- a/app/models/query.rb
+++ b/app/models/query.rb
@@ -577,8 +577,11 @@ class Query < ActiveRecord::Base
customized_class = queried_class.reflect_on_association(assoc.to_sym).klass.base_class rescue nil
raise "Unknown #{queried_class.name} association #{assoc}" unless customized_class
end
- "#{queried_table_name}.#{customized_key} #{not_in} IN (SELECT #{customized_class.table_name}.id FROM #{customized_class.table_name} LEFT OUTER JOIN #{db_table} ON #{db_table}.customized_type='#{customized_class}' AND #{db_table}.customized_id=#{customized_class.table_name}.id AND #{db_table}.custom_field_id=#{custom_field_id} WHERE " +
- sql_for_field(field, operator, value, db_table, db_field, true) + ')'
+ where = sql_for_field(field, operator, value, db_table, db_field, true)
+ if operator =~ /[<>]/
+ where = "(#{where}) AND #{db_table}.#{db_field} <> ''"
+ end
+ "#{queried_table_name}.#{customized_key} #{not_in} IN (SELECT #{customized_class.table_name}.id FROM #{customized_class.table_name} LEFT OUTER JOIN #{db_table} ON #{db_table}.customized_type='#{customized_class}' AND #{db_table}.customized_id=#{customized_class.table_name}.id AND #{db_table}.custom_field_id=#{custom_field_id} WHERE #{where})"
end
# Helper method to generate the WHERE sql for a +field+, +operator+ and a +value+