Created
June 14, 2022 17:55
-
-
Save andynu/9522d16ab85fd4ec2c2c31903fbe249d 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
# Add this to your config/initializers/ folder. | |
if Kernel.const_defined?('ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter') | |
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans = false | |
# Version 7.0.2 of activerecord-oracle_enhanced-adapter loads the types into | |
# a constant TYPE_MAP when the class is loaded | |
# | |
# This is so early in the process that there is no opertunity to change the | |
# default value of emulate_booleans, so that config is ineffective in that | |
# version. | |
# | |
# This monkey patch introduces a class variable with the type_map that we are | |
# able to reset after class loading. | |
# | |
# see https://github.com/rsim/oracle-enhanced/issues/2256 | |
class ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter | |
cattr_accessor :type_map | |
class << self | |
def reset_type_map! | |
self.type_map = ActiveRecord::Type::TypeMap.new.tap { |m| initialize_type_map(m) } | |
end | |
end | |
def type_map | |
self.class.type_map | |
end | |
end | |
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.reset_type_map! | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment