Defect #32737 » 32737_exclude_same_column_from_orderby.patch
| app/models/issue_query.rb | ||
|---|---|---|
|
unless ["#{Issue.table_name}.id ASC", "#{Issue.table_name}.id DESC"].any?{|i| order_option.include?(i)}
|
||
|
order_option << "#{Issue.table_name}.id DESC"
|
||
|
end
|
||
|
order_option = order_option.
|
||
|
collect{|s| s.split(/\s+(ASC|DESC)\s*,?\s*/i)}.flatten.each_slice(2).uniq(&:first).
|
||
|
collect{|arr| Arel.sql(arr.join(' '))}
|
||
|
scope = Issue.visible.
|
||
|
joins(:status, :project).
|
||
| ... | ... | |
|
unless ["#{Issue.table_name}.id ASC", "#{Issue.table_name}.id DESC"].any?{|i| order_option.include?(i)}
|
||
|
order_option << "#{Issue.table_name}.id DESC"
|
||
|
end
|
||
|
order_option = order_option.
|
||
|
collect{|s| s.split(/\s+(ASC|DESC)\s*,?\s*/i)}.flatten.each_slice(2).uniq(&:first).
|
||
|
collect{|arr| Arel.sql(arr.join(' '))}
|
||
|
Issue.visible.
|
||
|
joins(:status, :project).
|
||
| app/models/project_query.rb | ||
|---|---|---|
|
def results_scope(options={})
|
||
|
order_option = [group_by_sort_order, (options[:order] || sort_clause)].flatten.reject(&:blank?)
|
||
|
order_option << "#{Project.table_name}.lft ASC"
|
||
|
order_option = order_option.
|
||
|
collect{|s| s.split(/\s+(ASC|DESC)\s*,?\s*/i)}.flatten.each_slice(2).uniq(&:first).
|
||
|
collect{|arr| Arel.sql(arr.join(' '))}
|
||
|
scope = base_scope.
|
||
|
order(order_option).
|
||
|
joins(joins_for_order_statement(order_option.join(',')))
|
||
| app/models/time_entry_query.rb | ||
|---|---|---|
|
def results_scope(options={})
|
||
|
order_option = [group_by_sort_order, (options[:order] || sort_clause)].flatten.reject(&:blank?)
|
||
|
order_option << "#{TimeEntry.table_name}.id ASC"
|
||
|
order_option = order_option.
|
||
|
collect{|s| s.split(/\s+(ASC|DESC)\s*,?\s*/i)}.flatten.each_slice(2).uniq(&:first).
|
||
|
collect{|arr| Arel.sql(arr.join(' '))}
|
||
|
base_scope.
|
||
|
order(order_option).
|
||
|
joins(joins_for_order_statement(order_option.join(',')))
|
||