summaryrefslogtreecommitdiffstats
path: root/app/models/query.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2020-04-05 09:43:03 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2020-04-05 09:43:03 +0000
commitd6734e62397fff3b806b67d521b1080f6fab03b1 (patch)
tree05e75fa654c6306555af911b211d06bc4486529a /app/models/query.rb
parentc01dad40383c8dcee4df6d1d200467dee93335a4 (diff)
downloadredmine-d6734e62397fff3b806b67d521b1080f6fab03b1.tar.gz
redmine-d6734e62397fff3b806b67d521b1080f6fab03b1.zip
Fix sort does not work with group by datetime columns (#33110).
Patch by Marius BALTEANU. git-svn-id: http://svn.redmine.org/redmine/trunk@19655 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/query.rb')
-rw-r--r--app/models/query.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/app/models/query.rb b/app/models/query.rb
index cefe1a0ef..100728cff 100644
--- a/app/models/query.rb
+++ b/app/models/query.rb
@@ -850,7 +850,12 @@ class Query < ActiveRecord::Base
def group_by_sort_order
if column = group_by_column
order = (sort_criteria.order_for(column.name) || column.default_order || 'asc').try(:upcase)
- Array(column.sortable).map {|s| Arel.sql("#{s} #{order}")}
+
+ column_sortable = column.sortable
+ if column.is_a?(TimestampQueryColumn)
+ column_sortable = Redmine::Database.timestamp_to_date(column.sortable, User.current.time_zone)
+ end
+ Array(column_sortable).map {|s| Arel.sql("#{s} #{order}")}
end
end