]> source.dussan.org Git - redmine.git/commitdiff
Prevent sqlserver adapter from breaking the sub-query (#12713).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 4 Jan 2013 10:08:29 +0000 (10:08 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 4 Jan 2013 10:08:29 +0000 (10:08 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11116 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/issue_query.rb

index b0e282f8941ad978ba1bdaca68bd909614b0a073..81e6e1cefa2e4bedd9bd611bb45ceef4fff4df5e 100644 (file)
@@ -209,7 +209,7 @@ class IssueQuery < Query
       index = (index ? index + 1 : -1)
       # insert the column after estimated_hours or at the end
       @available_columns.insert index, QueryColumn.new(:spent_hours,
-        :sortable => "(SELECT COALESCE(SUM(hours), 0) FROM #{TimeEntry.table_name} WHERE #{TimeEntry.table_name}.issue_id = #{Issue.table_name}.id)",
+        :sortable => "COALESCE((SELECT SUM(hours) FROM #{TimeEntry.table_name} WHERE #{TimeEntry.table_name}.issue_id = #{Issue.table_name}.id), 0)",
         :default_order => 'desc',
         :caption => :label_spent_time
       )