Skip to content

Commit

Permalink
Merge pull request #32 from basecamp/fix-writeable-check-compatibility
Browse files Browse the repository at this point in the history
Fix writeable check compatibility
  • Loading branch information
anoldguy authored Jun 17, 2022
2 parents 8246d34 + e3b9455 commit 9c3a631
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 3 additions & 5 deletions lib/easymon/checks/active_record_mysql_writeable_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -21,7 +19,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
Expand Down
2 changes: 1 addition & 1 deletion lib/easymon/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Easymon
VERSION = "1.6.1"
VERSION = "1.6.2"
end

0 comments on commit 9c3a631

Please sign in to comment.