mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-19 15:01:14 +00:00
shorten long line of IssueQuery#sql_for_relations
git-svn-id: http://svn.redmine.org/redmine/trunk@20516 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
92f87076f1
commit
b81577a08d
@ -639,17 +639,40 @@ class IssueQuery < Query
|
|||||||
case operator
|
case operator
|
||||||
when "*", "!*"
|
when "*", "!*"
|
||||||
op = (operator == "*" ? 'IN' : 'NOT IN')
|
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 "=", "!"
|
when "=", "!"
|
||||||
op = (operator == "=" ? 'IN' : 'NOT IN')
|
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"
|
when "=p", "=!p", "!p"
|
||||||
op = (operator == "!p" ? 'NOT IN' : 'IN')
|
op = (operator == "!p" ? 'NOT IN' : 'IN')
|
||||||
comp = (operator == "=!p" ? '<>' : '=')
|
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"
|
when "*o", "!o"
|
||||||
op = (operator == "!o" ? 'NOT IN' : 'IN')
|
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
|
end
|
||||||
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)]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user