summaryrefslogtreecommitdiffstats
path: root/app/models/issue_query.rb
diff options
context:
space:
mode:
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>2020-11-29 12:48:31 +0000
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>2020-11-29 12:48:31 +0000
commitb81577a08d59cb51b3ccf6b84c9a485cdf8853a0 (patch)
tree942aaa8c63993b52c885932f5ded9e5d83000cf4 /app/models/issue_query.rb
parent92f87076f1b71f7b9c2d2dc34ff716698ff958a6 (diff)
downloadredmine-b81577a08d59cb51b3ccf6b84c9a485cdf8853a0.tar.gz
redmine-b81577a08d59cb51b3ccf6b84c9a485cdf8853a0.zip
shorten long line of IssueQuery#sql_for_relations
git-svn-id: http://svn.redmine.org/redmine/trunk@20516 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/issue_query.rb')
-rw-r--r--app/models/issue_query.rb31
1 files changed, 27 insertions, 4 deletions
diff --git a/app/models/issue_query.rb b/app/models/issue_query.rb
index 5d9e6799b..b81d9fbc8 100644
--- a/app/models/issue_query.rb
+++ b/app/models/issue_query.rb
@@ -639,17 +639,40 @@ class IssueQuery < Query
case operator
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 = '#{self.class.connection.quote_string(relation_type)}')"
+ "#{Issue.table_name}.id #{op}" \
+ " (SELECT DISTINCT #{IssueRelation.table_name}.#{join_column}" \
+ " FROM #{IssueRelation.table_name}" \
+ " WHERE #{IssueRelation.table_name}.relation_type =" \
+ " '#{self.class.connection.quote_string(relation_type)}')"
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 = '#{self.class.connection.quote_string(relation_type)}' AND #{IssueRelation.table_name}.#{target_join_column} = #{value.first.to_i})"
+ "#{Issue.table_name}.id #{op}" \
+ " (SELECT DISTINCT #{IssueRelation.table_name}.#{join_column}" \
+ " FROM #{IssueRelation.table_name}" \
+ " WHERE #{IssueRelation.table_name}.relation_type =" \
+ " '#{self.class.connection.quote_string(relation_type)}'" \
+ " AND #{IssueRelation.table_name}.#{target_join_column} = #{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 = '#{self.class.connection.quote_string(relation_type)}' AND #{IssueRelation.table_name}.#{target_join_column} = relissues.id AND relissues.project_id #{comp} #{value.first.to_i})"
+ "#{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 =" \
+ " '#{self.class.connection.quote_string(relation_type)}'" \
+ " AND #{IssueRelation.table_name}.#{target_join_column} = relissues.id" \
+ " AND relissues.project_id #{comp} #{value.first.to_i})"
when "*o", "!o"
op = (operator == "!o" ? 'NOT IN' : 'IN')
- "#{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 = '#{self.class.connection.quote_string(relation_type)}' AND #{IssueRelation.table_name}.#{target_join_column} = relissues.id AND relissues.status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed=#{self.class.connection.quoted_false}))"
+ "#{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 =" \
+ " '#{self.class.connection.quote_string(relation_type)}'" \
+ " AND #{IssueRelation.table_name}.#{target_join_column} = relissues.id" \
+ " AND relissues.status_id IN" \
+ " (SELECT id FROM #{IssueStatus.table_name}" \
+ " WHERE is_closed = #{self.class.connection.quoted_false}))"
end
if relation_options[:sym] == field && !options[:reverse]
sqls = [sql, sql_for_relations(field, operator, value, :reverse => true)]