Merged r12058 from trunk (#14401).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/2.3-stable@12062 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
2de51892ee
commit
5eeca35317
|
@ -393,10 +393,9 @@ class IssueQuery < Query
|
||||||
|
|
||||||
if relation_options[:sym] == field && !options[:reverse]
|
if relation_options[:sym] == field && !options[:reverse]
|
||||||
sqls = [sql, sql_for_relations(field, operator, value, :reverse => true)]
|
sqls = [sql, sql_for_relations(field, operator, value, :reverse => true)]
|
||||||
sqls.join(["!", "!*", "!p"].include?(operator) ? " AND " : " OR ")
|
sql = sqls.join(["!", "!*", "!p"].include?(operator) ? " AND " : " OR ")
|
||||||
else
|
|
||||||
sql
|
|
||||||
end
|
end
|
||||||
|
"(#{sql})"
|
||||||
end
|
end
|
||||||
|
|
||||||
IssueRelation::TYPES.keys.each do |relation_type|
|
IssueRelation::TYPES.keys.each do |relation_type|
|
||||||
|
|
|
@ -746,6 +746,21 @@ class QueryTest < ActiveSupport::TestCase
|
||||||
assert_equal [1, 2, 3], find_issues_with_query(query).map(&:id).sort
|
assert_equal [1, 2, 3], find_issues_with_query(query).map(&:id).sort
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_filter_on_relations_should_not_ignore_other_filter
|
||||||
|
issue = Issue.generate!
|
||||||
|
issue1 = Issue.generate!(:status_id => 1)
|
||||||
|
issue2 = Issue.generate!(:status_id => 2)
|
||||||
|
IssueRelation.create!(:relation_type => "relates", :issue_from => issue, :issue_to => issue1)
|
||||||
|
IssueRelation.create!(:relation_type => "relates", :issue_from => issue, :issue_to => issue2)
|
||||||
|
|
||||||
|
query = IssueQuery.new(:name => '_')
|
||||||
|
query.filters = {
|
||||||
|
"status_id" => {:operator => '=', :values => ['1']},
|
||||||
|
"relates" => {:operator => '=', :values => [issue.id.to_s]}
|
||||||
|
}
|
||||||
|
assert_equal [issue1], find_issues_with_query(query)
|
||||||
|
end
|
||||||
|
|
||||||
def test_statement_should_be_nil_with_no_filters
|
def test_statement_should_be_nil_with_no_filters
|
||||||
q = IssueQuery.new(:name => '_')
|
q = IssueQuery.new(:name => '_')
|
||||||
q.filters = {}
|
q.filters = {}
|
||||||
|
|
Loading…
Reference in New Issue