]> source.dussan.org Git - redmine.git/commitdiff
Issue description filter's 'none' operator does not match issues with blank descripti...
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 7 Mar 2017 17:51:27 +0000 (17:51 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 7 Mar 2017 17:51:27 +0000 (17:51 +0000)
Patch by Marius BALTEANU.

git-svn-id: http://svn.redmine.org/redmine/trunk@16378 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/query.rb
test/unit/query_test.rb

index 4f183329a41c9ac0fdfe6921a58c3b5a509090ae..321821a9394f621211e96ea35974e54ce8b7285e 100644 (file)
@@ -984,7 +984,7 @@ class Query < ActiveRecord::Base
       "  SELECT customized_id FROM #{CustomValue.table_name}" +
       "  WHERE customized_type='#{target_class}' AND custom_field_id=#{chained_custom_field_id}" +
       "  AND #{sql_for_field(field, operator, value, CustomValue.table_name, 'value')}))"
-    
+
   end
 
   def sql_for_custom_field_attribute(field, operator, value, custom_field_id, attribute)
@@ -1048,7 +1048,7 @@ class Query < ActiveRecord::Base
       end
     when "!*"
       sql = "#{db_table}.#{db_field} IS NULL"
-      sql << " OR #{db_table}.#{db_field} = ''" if is_custom_filter
+      sql << " OR #{db_table}.#{db_field} = ''" if (is_custom_filter || [:text, :string].include?(type_for(field)))
     when "*"
       sql = "#{db_table}.#{db_field} IS NOT NULL"
       sql << " AND #{db_table}.#{db_field} <> ''" if is_custom_filter
index 5a3283900f9548485fbb18c31140bd6e65b4ded4..7f2ef3d1cf973607f85ce773eb4671c805852c20 100644 (file)
@@ -217,6 +217,18 @@ class QueryTest < ActiveSupport::TestCase
     assert issues.all? {|i| i.custom_field_value(2).blank?}
   end
 
+  def test_operator_none_for_text
+    query = IssueQuery.new(:name => '_')
+    query.add_filter('status_id', '*', [''])
+    query.add_filter('description', '!*', [''])
+    assert query.has_filter?('description')
+    issues = find_issues_with_query(query)
+
+    assert issues.any?
+    assert issues.all? {|i| i.description.blank?}
+    assert_equal [11, 12], issues.map(&:id).sort
+  end
+
   def test_operator_all
     query = IssueQuery.new(:project => Project.find(1), :name => '_')
     query.add_filter('fixed_version_id', '*', [''])