Business intelligence made simple
Fixed async with caching
Andrew Kane7e39627ff176
diff --git a/lib/blazer/data_source.rb b/lib/blazer/data_source.rbindex 6832ee77..e75d0b9f 100644--- a/lib/blazer/data_source.rb+++ b/lib/blazer/data_source.rb@@ -97,7 +97,6 @@ module Blazerstatement = Statement.new(statement, self) if statement.is_a?(String)statement.bind unless statement.bind_statement- async = options[:async]result = nilif cache_mode != "off"if options[:refresh_cache]@@ -125,7 +124,17 @@ module Blazerif options[:run_id]comment << ",run_id:#{options[:run_id]}"end- result = run_statement_helper(statement, comment, async ? options[:run_id] : nil, options)+ result = run_statement_helper(statement, comment, options)+ end++ if options[:async] && options[:run_id]+ run_id = options[:run_id]+ begin+ result_cache.write_run(run_id, result)+ rescue+ result = Blazer::Result.new(self, [], [], "Error storing the results of this query :(", nil, false)+ result_cache.write_run(run_id, result)+ endendresult@@ -215,7 +224,7 @@ module Blazer@parameter_binding ||= adapter_instance.parameter_bindingend- def run_statement_helper(statement, comment, run_id, options)+ def run_statement_helper(statement, comment, options)start_time = Blazer.monotonic_timecolumns, rows, error =if adapter_instance.parameter_binding@@ -237,15 +246,6 @@ module Blazerendend- if run_id- begin- result_cache.write_run(run_id, result)- rescue- result = Blazer::Result.new(self, [], [], "Error storing the results of this query :(", nil, false)- result_cache.write_run(run_id, result)- end- end-result.cached_at = nilresultend