summaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2013-01-04 10:04:25 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2013-01-04 10:04:25 +0000
commita8083fb9a81d442be19cf3b528f2e4bc5bfe1ba5 (patch)
treed2e20418b4b487ff973a67e89e4bf9c274aaf4e0 /app/models
parent0337d9abc3590de73b1c13c932de82afd314709a (diff)
downloadredmine-a8083fb9a81d442be19cf3b528f2e4bc5bfe1ba5.tar.gz
redmine-a8083fb9a81d442be19cf3b528f2e4bc5bfe1ba5.zip
Pass the order option as an array to satisfy sqlserver adapter (#12713).
Unlike other adapters, the sqlserver adapter processes the order option and wipes it when using functions. Here we can see a "ASC" inserted in the COALESCE call: irb(main):001:0> Issue.order("coalesce(estimated_hours, 0), id").to_sql => "SELECT [issues].* FROM [issues] ORDER BY coalesce(estimated_hours ASC, 0) ASC, id ASC" This does not happen when passing the order SQL fragments separately. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11115 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models')
-rw-r--r--app/models/issue_query.rb10
1 files changed, 4 insertions, 6 deletions
diff --git a/app/models/issue_query.rb b/app/models/issue_query.rb
index 8f7002ad0..b0e282f89 100644
--- a/app/models/issue_query.rb
+++ b/app/models/issue_query.rb
@@ -270,14 +270,13 @@ class IssueQuery < Query
# Returns the issues
# Valid options are :order, :offset, :limit, :include, :conditions
def issues(options={})
- order_option = [group_by_sort_order, options[:order]].reject {|s| s.blank?}.join(',')
- order_option = nil if order_option.blank?
+ order_option = [group_by_sort_order, options[:order]].flatten.reject(&:blank?)
issues = Issue.visible.where(options[:conditions]).all(
:include => ([:status, :project] + (options[:include] || [])).uniq,
:conditions => statement,
:order => order_option,
- :joins => joins_for_order_statement(order_option),
+ :joins => joins_for_order_statement(order_option.join(',')),
:limit => options[:limit],
:offset => options[:offset]
)
@@ -295,13 +294,12 @@ class IssueQuery < Query
# Returns the issues ids
def issue_ids(options={})
- order_option = [group_by_sort_order, options[:order]].reject {|s| s.blank?}.join(',')
- order_option = nil if order_option.blank?
+ order_option = [group_by_sort_order, options[:order]].flatten.reject(&:blank?)
Issue.visible.scoped(:conditions => options[:conditions]).scoped(:include => ([:status, :project] + (options[:include] || [])).uniq,
:conditions => statement,
:order => order_option,
- :joins => joins_for_order_statement(order_option),
+ :joins => joins_for_order_statement(order_option.join(',')),
:limit => options[:limit],
:offset => options[:offset]).find_ids
rescue ::ActiveRecord::StatementInvalid => e