mirror of
https://github.com/meineerde/redmine.git
synced 2026-02-01 03:57:15 +00:00
Fix "contains any of" operator is not taken into account in File and File description filters (#38435).
git-svn-id: https://svn.redmine.org/redmine/trunk@22195 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
ea1c8ea319
commit
1f5c8742e3
@ -614,13 +614,13 @@ class IssueQuery < Query
|
||||
when "*", "!*"
|
||||
e = (operator == "*" ? "EXISTS" : "NOT EXISTS")
|
||||
"#{e} (SELECT 1 FROM #{Attachment.table_name} a WHERE a.container_type = 'Issue' AND a.container_id = #{Issue.table_name}.id)"
|
||||
when "~", "!~"
|
||||
c = sql_contains("a.filename", value.first)
|
||||
e = (operator == "~" ? "EXISTS" : "NOT EXISTS")
|
||||
"#{e} (SELECT 1 FROM #{Attachment.table_name} a WHERE a.container_type = 'Issue' AND a.container_id = #{Issue.table_name}.id AND #{c})"
|
||||
when "~", "!~", "|~"
|
||||
c = sql_contains("a.filename", value.first, :all_words => (operator != "|~"))
|
||||
e = (operator == "!~" ? "NOT EXISTS" : "EXISTS")
|
||||
"#{e} (SELECT 1 FROM #{Attachment.table_name} a WHERE a.container_type = 'Issue' AND a.container_id = #{Issue.table_name}.id AND (#{c}))"
|
||||
when "^", "$"
|
||||
c = sql_contains("a.filename", value.first, (operator == "^" ? :starts_with : :ends_with) => true)
|
||||
"EXISTS (SELECT 1 FROM #{Attachment.table_name} a WHERE a.container_type = 'Issue' AND a.container_id = #{Issue.table_name}.id AND #{c})"
|
||||
"EXISTS (SELECT 1 FROM #{Attachment.table_name} a WHERE a.container_type = 'Issue' AND a.container_id = #{Issue.table_name}.id AND (#{c}))"
|
||||
end
|
||||
end
|
||||
|
||||
@ -630,15 +630,15 @@ class IssueQuery < Query
|
||||
case operator
|
||||
when '*', '!*'
|
||||
(operator == '*' ? cond_description : "NOT (#{cond_description})")
|
||||
when '~', '!~'
|
||||
when '~', '!~', '|~'
|
||||
(operator == '~' ? '' : "#{cond_description} AND ") +
|
||||
sql_contains('a.description', value.first, :match => (operator == '~'))
|
||||
sql_contains('a.description', value.first, :match => (operator != '!~'), :all_words => (operator != '|~'))
|
||||
when '^', '$'
|
||||
sql_contains('a.description', value.first, (operator == '^' ? :starts_with : :ends_with) => true)
|
||||
else
|
||||
'1=0'
|
||||
end
|
||||
"EXISTS (SELECT 1 FROM #{Attachment.table_name} a WHERE a.container_type = 'Issue' AND a.container_id = #{Issue.table_name}.id AND #{c})"
|
||||
"EXISTS (SELECT 1 FROM #{Attachment.table_name} a WHERE a.container_type = 'Issue' AND a.container_id = #{Issue.table_name}.id AND (#{c}))"
|
||||
end
|
||||
|
||||
def sql_for_parent_id_field(field, operator, value)
|
||||
|
||||
@ -767,6 +767,36 @@ class QueryTest < ActiveSupport::TestCase
|
||||
assert_equal [1, 2, 3], result.map(&:id).sort
|
||||
end
|
||||
|
||||
def test_operator_contains_any_of_with_attachment
|
||||
User.current = User.find(1)
|
||||
query = IssueQuery.new(
|
||||
:name => '_',
|
||||
:filters => {
|
||||
'attachment' => {
|
||||
:operator => '|~',
|
||||
:values => ['source changeset']
|
||||
}
|
||||
}
|
||||
)
|
||||
result = find_issues_with_query(query)
|
||||
assert_equal [2, 3], result.map(&:id).sort
|
||||
end
|
||||
|
||||
def test_operator_contsins_any_of_with_attachment_description
|
||||
User.current = User.find(1)
|
||||
query = IssueQuery.new(
|
||||
:name => '_',
|
||||
:filters => {
|
||||
'attachment_description' => {
|
||||
:operator => '|~',
|
||||
:values => ['ruby issue']
|
||||
}
|
||||
}
|
||||
)
|
||||
result = find_issues_with_query(query)
|
||||
assert_equal [2, 14], result.map(&:id).sort
|
||||
end
|
||||
|
||||
def test_range_for_this_week_with_week_starting_on_monday
|
||||
I18n.locale = :fr
|
||||
assert_equal '1', I18n.t(:general_first_day_of_week)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user