diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-10-04 18:10:41 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-10-04 18:10:41 +0000 |
commit | b9d7c22297206eca2562b94a32390725b57ad75e (patch) | |
tree | 02c356772d67885250296eb4593870c556e1c42f /app/models/query.rb | |
parent | 44137cb1d4378631077aaec47f841d31a467468a (diff) | |
download | redmine-b9d7c22297206eca2562b94a32390725b57ad75e.tar.gz redmine-b9d7c22297206eca2562b94a32390725b57ad75e.zip |
Adds no_issue_in_project operator for relations filter (#3265).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10559 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/query.rb')
-rw-r--r-- | app/models/query.rb | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/app/models/query.rb b/app/models/query.rb index dfb00825d..fb708dfb3 100644 --- a/app/models/query.rb +++ b/app/models/query.rb @@ -115,7 +115,8 @@ class Query < ActiveRecord::Base "~" => :label_contains, "!~" => :label_not_contains, "=p" => :label_any_issues_in_project, - "=!p" => :label_any_issues_not_in_project} + "=!p" => :label_any_issues_not_in_project, + "!p" => :label_no_issues_in_project} cattr_reader :operators @@ -129,7 +130,7 @@ class Query < ActiveRecord::Base :text => [ "~", "!~", "!*", "*" ], :integer => [ "=", ">=", "<=", "><", "!*", "*" ], :float => [ "=", ">=", "<=", "><", "!*", "*" ], - :relation => ["=", "=p", "=!p", "!*", "*"]} + :relation => ["=", "=p", "=!p", "!p", "!*", "*"]} cattr_reader :operators_by_filter_type @@ -807,14 +808,15 @@ class Query < ActiveRecord::Base when "=", "!" op = (operator == "=" ? 'IN' : 'NOT IN') "#{Issue.table_name}.id #{op} (SELECT DISTINCT #{IssueRelation.table_name}.#{join_column} FROM #{IssueRelation.table_name} WHERE #{IssueRelation.table_name}.relation_type = '#{connection.quote_string(relation_type)}' AND #{IssueRelation.table_name}.#{target_join_column} = #{value.first.to_i})" - when "=p", "=!p" - op = (operator == "=p" ? '=' : '<>') - "#{Issue.table_name}.id IN (SELECT DISTINCT #{IssueRelation.table_name}.#{join_column} FROM #{IssueRelation.table_name}, #{Issue.table_name} relissues WHERE #{IssueRelation.table_name}.relation_type = '#{connection.quote_string(relation_type)}' AND #{IssueRelation.table_name}.#{target_join_column} = relissues.id AND relissues.project_id #{op} #{value.first.to_i})" + when "=p", "=!p", "!p" + op = (operator == "!p" ? 'NOT IN' : 'IN') + comp = (operator == "=!p" ? '<>' : '=') + "#{Issue.table_name}.id #{op} (SELECT DISTINCT #{IssueRelation.table_name}.#{join_column} FROM #{IssueRelation.table_name}, #{Issue.table_name} relissues WHERE #{IssueRelation.table_name}.relation_type = '#{connection.quote_string(relation_type)}' AND #{IssueRelation.table_name}.#{target_join_column} = relissues.id AND relissues.project_id #{comp} #{value.first.to_i})" end if relation_options[:sym] == field && !options[:reverse] sqls = [sql, sql_for_relations(field, operator, value, :reverse => true)] - sqls.join(["!", "!*"].include?(operator) ? " AND " : " OR ") + sqls.join(["!", "!*", "!p"].include?(operator) ? " AND " : " OR ") else sql end |