summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2015-04-12 09:44:32 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2015-04-12 09:44:32 +0000
commit9cb9f67055ebd97ab348af6b5c2c1df828bc1f74 (patch)
tree806516df7625a0e96ca9cfa084934a225d633d63 /app
parent78153cacdf3de97bc58bdc7fb57010a2d9874f34 (diff)
downloadredmine-9cb9f67055ebd97ab348af6b5c2c1df828bc1f74.tar.gz
redmine-9cb9f67055ebd97ab348af6b5c2c1df828bc1f74.zip
SQL error with SQLServer when grouping+sorting issues (#19544).
git-svn-id: http://svn.redmine.org/redmine/trunk@14165 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/helpers/sort_helper.rb13
1 files changed, 9 insertions, 4 deletions
diff --git a/app/helpers/sort_helper.rb b/app/helpers/sort_helper.rb
index c9da9bd10..d6ac8bd22 100644
--- a/app/helpers/sort_helper.rb
+++ b/app/helpers/sort_helper.rb
@@ -85,7 +85,7 @@ module SortHelper
sql = @criteria.collect do |k,o|
if s = @available_criteria[k]
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.flatten.compact
sql.blank? ? nil : sql
@@ -129,14 +129,19 @@ module SortHelper
self
end
- # Appends DESC to the sort criterion unless it has a fixed order
- def append_desc(criterion)
+ # Appends ASC/DESC to the sort criterion unless it has a fixed order
+ def append_order(criterion, order)
if criterion =~ / (asc|desc)$/i
criterion
else
- "#{criterion} DESC"
+ "#{criterion} #{order}"
end
end
+
+ # Appends DESC to the sort criterion unless it has a fixed order
+ def append_desc(criterion)
+ append_order(criterion, "DESC")
+ end
end
def sort_name