Skip to content

Commit

Permalink
update MiqReport::Search to include all columns
Browse files Browse the repository at this point in the history
When generating a query for a report, ensure that the columns necessary
to join to other models are brought back.

If a report needs additional columns for join models and the models are
not part of the includes_for_find attribute, then ensure all columns
including the join keys are in cols: attribute, and just the visible
columns are in the col_order attribute
  • Loading branch information
kbrock committed Nov 14, 2018
1 parent a1ba9b0 commit 799ef64
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion app/models/miq_report/search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,19 @@ def paged_view_search(options = {})

search_options = options.merge(:class => db, :conditions => conditions, :include_for_find => includes)
search_options.merge!(:limit => limit, :offset => offset, :order => order) if order
search_options[:extra_cols] = va_sql_cols if va_sql_cols.present?

extra_cols = if includes
includes.keys.map do |rel|
if (rel = db_class.reflect_on_association(rel))
# adding primary_key is probably over kill.
rel.macro == :belongs_to ? rel.foreign_key : db_class.primary_key
end
end.compact
else
[]
end
extra_cols += va_sql_cols if va_sql_cols.present?
search_options[:extra_cols] = extra_cols if extra_cols.present?

if options[:parent]
targets = get_parent_targets(options[:parent], options[:association] || options[:parent_method])
Expand Down

0 comments on commit 799ef64

Please sign in to comment.