Created
May 24, 2021 05:05
-
-
Save jpawlyn/5c09411f7da37d953c4ae639bcf41458 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "#{Gem.loaded_specs['activerecord'].full_gem_path}/lib/active_record/connection_adapters/abstract_adapter" | |
module ActiveRecord | |
module ConnectionAdapters | |
class AbstractAdapter | |
# we are overriding this method since connection_klass is a string when accessing a MyGem db | |
def preventing_writes? | |
return true if replica? | |
return ActiveRecord::Base.connection_handler.prevent_writes if ActiveRecord::Base.legacy_connection_handling | |
# commented out line below and replaced with an expanded guard clause | |
# return false if connection_klass.nil? | |
return false if connection_klass.nil? || connection_klass.is_a?(String) | |
connection_klass.current_preventing_writes | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment