Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save andynu/9522d16ab85fd4ec2c2c31903fbe249d to your computer and use it in GitHub Desktop.
Save andynu/9522d16ab85fd4ec2c2c31903fbe249d to your computer and use it in GitHub Desktop.
# 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