Skip to content

Business intelligence made simple

Raise error when timeout not supported

Andrew Kane06d5ef638fe1
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 10a7e7a6..83648d80 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,7 @@
- Switched to Chart.js for charts
- Better output for explain
- Support for MySQL timeouts
+- Raise error when timeout not supported
## 1.2.1
diff --git a/lib/blazer.rb b/lib/blazer.rb
index b3ba56cf..d817d76e 100644
--- a/lib/blazer.rb
+++ b/lib/blazer.rb
@@ -6,6 +6,8 @@ require "blazer/data_source"
require "blazer/engine"
module Blazer
+ class TimeoutNotSupported < StandardError; end
+
class << self
attr_accessor :audit
attr_reader :time_zone
diff --git a/lib/blazer/data_source.rb b/lib/blazer/data_source.rb
index 6d341020..2554bba7 100644
--- a/lib/blazer/data_source.rb
+++ b/lib/blazer/data_source.rb
@@ -84,6 +84,8 @@ module Blazer
connection_model.connection.execute("SET statement_timeout = #{timeout.to_i * 1000}")
elsif mysql?
connection_model.connection.execute("SET max_execution_time = #{timeout.to_i * 1000}")
+ else
+ raise Blazer::TimeoutNotSupported, "Timeout not supported for #{adapter_name} adapter"
end
end
@@ -146,11 +148,8 @@ module Blazer
def in_transaction
if use_transaction?
connection_model.transaction do
- begin
- yield
- ensure
- raise ActiveRecord::Rollback
- end
+ yield
+ raise ActiveRecord::Rollback
end
else
yield