mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-19 15:01:14 +00:00
SQL error with SQLServer when grouping+sorting issues (#19544).
git-svn-id: http://svn.redmine.org/redmine/trunk@14165 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
78153cacdf
commit
9cb9f67055
@ -85,7 +85,7 @@ module SortHelper
|
|||||||
sql = @criteria.collect do |k,o|
|
sql = @criteria.collect do |k,o|
|
||||||
if s = @available_criteria[k]
|
if s = @available_criteria[k]
|
||||||
s = [s] unless s.is_a?(Array)
|
s = [s] unless s.is_a?(Array)
|
||||||
(o ? s : s.collect {|c| append_desc(c)})
|
s.collect {|c| append_order(c, o ? "ASC" : "DESC")}
|
||||||
end
|
end
|
||||||
end.flatten.compact
|
end.flatten.compact
|
||||||
sql.blank? ? nil : sql
|
sql.blank? ? nil : sql
|
||||||
@ -129,14 +129,19 @@ module SortHelper
|
|||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
# Appends DESC to the sort criterion unless it has a fixed order
|
# Appends ASC/DESC to the sort criterion unless it has a fixed order
|
||||||
def append_desc(criterion)
|
def append_order(criterion, order)
|
||||||
if criterion =~ / (asc|desc)$/i
|
if criterion =~ / (asc|desc)$/i
|
||||||
criterion
|
criterion
|
||||||
else
|
else
|
||||||
"#{criterion} DESC"
|
"#{criterion} #{order}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Appends DESC to the sort criterion unless it has a fixed order
|
||||||
|
def append_desc(criterion)
|
||||||
|
append_order(criterion, "DESC")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def sort_name
|
def sort_name
|
||||||
|
|||||||
@ -265,6 +265,14 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
assert_not_nil assigns(:issue_count_by_group)
|
assert_not_nil assigns(:issue_count_by_group)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_index_with_query_grouped_and_sorted_by_category
|
||||||
|
get :index, :project_id => 1, :set_filter => 1, :group_by => "category", :sort => "category"
|
||||||
|
assert_response :success
|
||||||
|
assert_template 'index'
|
||||||
|
assert_not_nil assigns(:issues)
|
||||||
|
assert_not_nil assigns(:issue_count_by_group)
|
||||||
|
end
|
||||||
|
|
||||||
def test_index_with_query_grouped_by_list_custom_field
|
def test_index_with_query_grouped_by_list_custom_field
|
||||||
get :index, :project_id => 1, :query_id => 9
|
get :index, :project_id => 1, :query_id => 9
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user