From efa2ea43504571ed0079158cc7b0dde24041a71b Mon Sep 17 00:00:00 2001 From: Nathan Anderson Date: Fri, 17 Jun 2022 13:50:02 -0400 Subject: [PATCH 1/2] Use a syntax that works with both mysql and mysql2 gems --- lib/easymon/checks/active_record_mysql_writeable_check.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/easymon/checks/active_record_mysql_writeable_check.rb b/lib/easymon/checks/active_record_mysql_writeable_check.rb index 88e9276..5b09806 100644 --- a/lib/easymon/checks/active_record_mysql_writeable_check.rb +++ b/lib/easymon/checks/active_record_mysql_writeable_check.rb @@ -21,7 +21,7 @@ def check private def database_writeable? - klass.connection.execute(@query).entries.flatten.first == 0 + klass.connection.execute(@query).to_enum.first.first.to_i == 0 rescue false end From e3b94555b19b131f5e5066ae4159c8c8bd3f5a5a Mon Sep 17 00:00:00 2001 From: Nathan Anderson Date: Fri, 17 Jun 2022 13:50:44 -0400 Subject: [PATCH 2/2] Remove 'makara: true' flag; use the `for UPDATE` syntax in all cases --- lib/easymon/checks/active_record_mysql_writeable_check.rb | 6 ++---- lib/easymon/version.rb | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/easymon/checks/active_record_mysql_writeable_check.rb b/lib/easymon/checks/active_record_mysql_writeable_check.rb index 5b09806..e17ac70 100644 --- a/lib/easymon/checks/active_record_mysql_writeable_check.rb +++ b/lib/easymon/checks/active_record_mysql_writeable_check.rb @@ -2,11 +2,9 @@ module Easymon class ActiveRecordMysqlWriteableCheck attr_accessor :klass - def initialize(klass, makara = false) + def initialize(klass) self.klass = klass - @query = "SELECT @@read_only" - # Trick makara into using the primary db - @query += " for UPDATE" if makara + @query = "SELECT @@read_only for UPDATE" end def check diff --git a/lib/easymon/version.rb b/lib/easymon/version.rb index 7cb8b15..da29c31 100644 --- a/lib/easymon/version.rb +++ b/lib/easymon/version.rb @@ -1,3 +1,3 @@ module Easymon - VERSION = "1.6.1" + VERSION = "1.6.2" end