diff options
-rw-r--r-- | app/models/issue_query.rb | 11 | ||||
-rw-r--r-- | app/models/query.rb | 4 |
2 files changed, 12 insertions, 3 deletions
diff --git a/app/models/issue_query.rb b/app/models/issue_query.rb index 56ef9f08e..66f520d64 100644 --- a/app/models/issue_query.rb +++ b/app/models/issue_query.rb @@ -323,7 +323,7 @@ class IssueQuery < Query def issues(options={}) order_option = [group_by_sort_order, options[:order]].flatten.reject(&:blank?) - issues = Issue.visible. + scope = Issue.visible. joins(:status, :project). where(statement). includes(([:status, :project] + (options[:include] || [])).uniq). @@ -331,8 +331,13 @@ class IssueQuery < Query order(order_option). joins(joins_for_order_statement(order_option.join(','))). limit(options[:limit]). - offset(options[:offset]). - all + offset(options[:offset]) + + if has_custom_field_column? + scope = scope.preload(:custom_values) + end + + issues = scope.all if has_column?(:spent_hours) Issue.load_visible_spent_hours(issues) diff --git a/app/models/query.rb b/app/models/query.rb index ca04f29b5..7582d73bc 100644 --- a/app/models/query.rb +++ b/app/models/query.rb @@ -449,6 +449,10 @@ class Query < ActiveRecord::Base column_names && column_names.include?(column.is_a?(QueryColumn) ? column.name : column) end + def has_custom_field_column? + columns.any? {|column| column.is_a? QueryCustomFieldColumn} + end + def has_default_columns? column_names.nil? || column_names.empty? end |