Business intelligence made simple
Allow for nil smart column with hash format
Andrew Kanef358e7ce30f6
diff --git a/app/views/blazer/queries/run.html.erb b/app/views/blazer/queries/run.html.erbindex e5540bb8..4639e700 100644--- a/app/views/blazer/queries/run.html.erb+++ b/app/views/blazer/queries/run.html.erb@@ -141,10 +141,10 @@<% else %><%= blazer_format_value(k, v) %><% end %>+ <% end %>- <% if v2 = (@boom[k] || {})[v.to_s] %>- <div class="text-muted"><%= v2 %></div>- <% end %>+ <% if v2 = (@boom[k] || {})[v.nil? ? v : v.to_s] %>+ <div class="text-muted"><%= v2 %></div><% end %></td><% end %>diff --git a/lib/blazer/result.rb b/lib/blazer/result.rbindex ccef8ae2..086edaad 100644--- a/lib/blazer/result.rb+++ b/lib/blazer/result.rb@@ -25,13 +25,16 @@ module Blazercolumns.each_with_index do |key, i|query = data_source.smart_columns[key]if query- if query.is_a?(Hash)- boom[key] = query.stringify_keys- else- values = rows.map { |r| r[i] }.compact.uniq- result = data_source.run_statement(ActiveRecord::Base.send(:sanitize_sql_array, [query.sub("{value}", "(?)"), values]))- boom[key] = Hash[result.rows.map { |k, v| [k.to_s, v] }]- end+ res =+ if query.is_a?(Hash)+ query+ else+ values = rows.map { |r| r[i] }.compact.uniq+ result = data_source.run_statement(ActiveRecord::Base.send(:sanitize_sql_array, [query.sub("{value}", "(?)"), values]))+ result.rows+ end++ boom[key] = Hash[res.map { |k, v| [k.nil? ? k : k.to_s, v] }]endendboom