mirror of
https://github.com/redmine/redmine.git
synced 2026-07-13 13:03:16 +02:00
Filter operator "doesn't contain" on custom fields ignores issues with no value (#38055).
Patch by Tomoko Shimizu (user:tomokosimi), Takashi Kato (user:tohosaku), Mizuki ISHIKAWA (user:ishikawa999) and Ko Nagase (user:sanak). git-svn-id: https://svn.redmine.org/redmine/trunk@24432 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -1448,6 +1448,7 @@ class Query < ApplicationRecord
|
||||
sql = sql_contains("#{db_table}.#{db_field}", value.first)
|
||||
when "!~"
|
||||
sql = sql_contains("#{db_table}.#{db_field}", value.first, :match => false)
|
||||
sql += " OR #{db_table}.#{db_field} IS NULL" if is_custom_filter
|
||||
when "*~"
|
||||
sql = sql_contains("#{db_table}.#{db_field}", value.first, :all_words => false)
|
||||
when "^"
|
||||
|
||||
@@ -739,6 +739,15 @@ class QueryTest < ActiveSupport::TestCase
|
||||
assert_not_include issue, result
|
||||
end
|
||||
|
||||
def test_operator_does_not_contain_on_text_custom_field
|
||||
query = IssueQuery.new(:name => '_')
|
||||
query.filters = {"cf_2" => {:operator => '!~', :values => ['125']}}
|
||||
result = find_issues_with_query(query)
|
||||
# "cf_2" (Searchable field) custom field's available trackers are only 1:Bug and 3:Support request.
|
||||
# 8(Issue.visible.where(tracker: [1,3])) - 2(contain "125") = 6(not contain "125")
|
||||
assert_equal 6, result.size
|
||||
end
|
||||
|
||||
def test_operator_contains_any_of
|
||||
User.current = User.find(1)
|
||||
query = IssueQuery.new(
|
||||
|
||||
Reference in New Issue
Block a user