Skip to content

Commit

Permalink
do not assume field label is a string (could be a symbol), and do not…
Browse files Browse the repository at this point in the history
… assume that the aggregate tables already exist for checking last inserted record.
  • Loading branch information
kookster committed Nov 17, 2011
1 parent aff803b commit 680415d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/active_warehouse/aggregate/pipelined_rolap_aggregate.rb
Expand Up @@ -310,7 +310,8 @@ def create_aggregate_table(base_name, dimension_fields, current_levels, options)
def find_latest_record(base_name, dimension_fields, current_levels, options={})
target_rollup = aggregate_rollup_name(base_name, current_levels)
new_rec_dim_class = self.new_records_only ? fact_class.dimension_class(new_records_dimension) : nil
if (self.new_records_only && !self.new_records_record)

if (self.new_records_only && !self.new_records_record && connection.tables.include?(target_rollup))
latest = nil
new_records_field = dimension_fields[new_rec_dim_class].last
find_latest_sql = "SELECT #{new_records_field} AS latest FROM #{target_rollup} GROUP BY #{new_records_field} ORDER BY #{new_records_field} DESC LIMIT #{[(new_records_offset - 1), 0].max}, 1"
Expand Down
2 changes: 1 addition & 1 deletion lib/active_warehouse/field.rb
Expand Up @@ -59,7 +59,7 @@ def column_type
# convert the label into something we can use in a table.
# i.e., 'Sum of Transactions' becomes 'sum_of_transactions'
def label_for_table
label.gsub(/ /, '_').downcase
label.to_s.gsub(/ /, '_').downcase
end

# returns the table name that has this fact column
Expand Down

0 comments on commit 680415d

Please sign in to comment.