rsim / oracle-enhanced

Oracle enhaced adapter for ActiveRecord
MIT License
545 stars 307 forks source link

OracleEnhancedAdapter.emulate_booleans doesn't work #2256

Closed areman closed 1 year ago

areman commented 2 years ago

On load of OracleEnhancedAdapter the TYPE_MAP will be initialized. But that makes it impossible to set OracleEnhancedAdapter.emulate_booleans = false. To set it to false you need to require the ruby source file, and OracleEnhancedAdapter.emulate_booleans = false is always set after the TYPE_MAP is nitialized.

andynu commented 2 years ago

Just encountered this issue. We believe the issue was introduced in this commit https://github.com/rsim/oracle-enhanced/commit/34ca92b39cc048d490db71dd8fb8284579b87c48

andynu commented 2 years ago

Here is a monkey patching initializer workaround. https://gist.github.com/andynu/9522d16ab85fd4ec2c2c31903fbe249d

andynu commented 2 years ago

Would the maintainers be interested in a PR along the lines of the workaround? Converting the TYPE_MAP constant into a class attribute? I'd be happy to provide one, but wasn't sure if that is the direction you'd like to go since it would involve re-parsing the mappings later in the load process. I'm not sure if there is a better approach to more lazily set the type_map so that the configs can be set before the first time it is initialized.

yahonda commented 2 years ago

I am happy to review pull requests with tests. https://github.com/rsim/oracle-enhanced/pull/2199 aims to reduce amount of memory in Rails 7.0. So converting the TYPE_MAP into constant may introduce the same memory usage as Rails 6.1 or older.

yahonda commented 1 year ago

Closed via #2301