mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-24 09:21:12 +00:00
Filter on issue ID with between/lesser/greater operator does not work (#23596).
git-svn-id: http://svn.redmine.org/redmine/trunk@15751 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
d5ca4a3593
commit
9f9232381a
@ -466,11 +466,16 @@ class IssueQuery < Query
|
||||
end
|
||||
|
||||
def sql_for_issue_id_field(field, operator, value)
|
||||
ids = value.first.to_s.scan(/\d+/).map(&:to_i).join(",")
|
||||
if ids.present?
|
||||
"#{Issue.table_name}.id IN (#{ids})"
|
||||
if operator == "="
|
||||
# accepts a comma separated list of ids
|
||||
ids = value.first.to_s.scan(/\d+/).map(&:to_i)
|
||||
if ids.present?
|
||||
"#{Issue.table_name}.id IN (#{ids.join(",")})"
|
||||
else
|
||||
"1=0"
|
||||
end
|
||||
else
|
||||
"1=0"
|
||||
sql_for_field("id", operator, value, Issue.table_name, "id")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -235,7 +235,7 @@ class QueryTest < ActiveSupport::TestCase
|
||||
assert_equal 2, issues.first.id
|
||||
end
|
||||
|
||||
def test_operator_is_on_integer_should_accept_comma_separated_values
|
||||
def test_operator_is_on_issue_id_should_accept_comma_separated_values
|
||||
query = IssueQuery.new(:name => '_')
|
||||
query.add_filter("issue_id", '=', ['1,3'])
|
||||
issues = find_issues_with_query(query)
|
||||
@ -243,6 +243,14 @@ class QueryTest < ActiveSupport::TestCase
|
||||
assert_equal [1,3], issues.map(&:id).sort
|
||||
end
|
||||
|
||||
def test_operator_between_on_issue_id_should_return_range
|
||||
query = IssueQuery.new(:name => '_')
|
||||
query.add_filter("issue_id", '><', ['2','3'])
|
||||
issues = find_issues_with_query(query)
|
||||
assert_equal 2, issues.size
|
||||
assert_equal [2,3], issues.map(&:id).sort
|
||||
end
|
||||
|
||||
def test_operator_is_on_integer_custom_field
|
||||
f = IssueCustomField.create!(:name => 'filter', :field_format => 'int', :is_for_all => true, :is_filter => true, :trackers => Tracker.all)
|
||||
CustomValue.create!(:custom_field => f, :customized => Issue.find(1), :value => '7')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user