Feature #38301 » 2023-02-25-issue-relation-filter.patch
app/models/issue_query.rb | ||
---|---|---|
723 | 723 |
relation_type = relation_options[:reverse] || relation_type |
724 | 724 |
join_column, target_join_column = target_join_column, join_column |
725 | 725 |
end |
726 |
ids = value.first.to_s.scan(/\d+/).map(&:to_i).uniq |
|
726 | 727 |
sql = |
727 | 728 |
case operator |
728 | 729 |
when "*", "!*" |
... | ... | |
739 | 740 |
" FROM #{IssueRelation.table_name}" \ |
740 | 741 |
" WHERE #{IssueRelation.table_name}.relation_type =" \ |
741 | 742 |
" '#{self.class.connection.quote_string(relation_type)}'" \ |
742 |
" AND #{IssueRelation.table_name}.#{target_join_column} = #{value.first.to_i})"
|
|
743 |
" AND #{IssueRelation.table_name}.#{target_join_column} IN (#{ids.join(",")}))"
|
|
743 | 744 |
when "=p", "=!p", "!p" |
744 | 745 |
op = (operator == "!p" ? 'NOT IN' : 'IN') |
745 | 746 |
comp = (operator == "=!p" ? '<>' : '=') |
test/unit/query_test.rb | ||
---|---|---|
1337 | 1337 |
query.filters = {"relates" => {:operator => '=', :values => ['2']}} |
1338 | 1338 |
assert_equal [1], find_issues_with_query(query).map(&:id).sort |
1339 | 1339 | |
1340 |
query = IssueQuery.new(:name => '_') |
|
1341 |
query.filters = {"relates" => {:operator => '=', :values => ['1,2']}} |
|
1342 |
assert_equal [1, 2, 3], find_issues_with_query(query).map(&:id).sort |
|
1343 | ||
1340 | 1344 |
query = IssueQuery.new(:name => '_') |
1341 | 1345 |
query.filters = {"relates" => {:operator => '!', :values => ['1']}} |
1342 | 1346 |
assert_equal Issue.where.not(:id => [2, 3]).order(:id).ids, find_issues_with_query(query).map(&:id).sort |
1347 | ||
1348 |
query = IssueQuery.new(:name => '_') |
|
1349 |
query.filters = {"relates" => {:operator => '!', :values => ['1,2']}} |
|
1350 |
assert_equal Issue.where.not(:id => [1, 2, 3]).order(:id).ids, find_issues_with_query(query).map(&:id).sort |
|
1343 | 1351 |
end |
1344 | 1352 | |
1345 | 1353 |
def test_filter_on_relations_with_any_issues_in_a_project |