rsim / oracle-enhanced

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

emulate_booleans = false no longer being picked up in rails 7.0.4 #2313

Open toddwf opened 1 year ago

toddwf commented 1 year ago

Steps to reproduce

I am in the process of updating a rails application from rails 6.1.4 on ruby 3.0.4p208 to 7.0.4 on ruby 3.1.3 stable. I had passing tests on 6.1.4 ruby 3.1.3 stable, but failures on 7.0.4 r3.1.3 stable and I have traced them to a failure of my emulate_booleans setting in my application.rb file to be picked up. It is set to false. It is being treated as if it is set to true in the rails 7 configuration.

I tried creating a separate initializer oracle.rb but that had no impact.

I manually edited the oracle_enhanced_adapter.rb file and set emulate_booleans to false and my application and tests ran normally and as expected so I can confirm the setting is no longer being picked up in my application.rb or initializers.

Expected behavior

ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans = false in my application.rb file should allow my NUMBER(1) columns to be treated as integers instead of booleans. This was happening for instances of my application up to and including rails 6.1.4 ruby 3.1.3 stable.

Actual behavior

ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans = false in my application.rb file is being ignored and any NUMBER(1) columns in my application are being treated as booleans, which breaks my application and its tests.

System configuration

Rails version: 7.0.4

Oracle enhanced adapter version: 7.0.2

Ruby version: 3.1.3 stable

Oracle Database version: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit

NOTE: I am using cpk gem: gem 'composite_primary_keys', '~> 14.0.4' also "ruby-oci8", "~> 2.2.12" and "ruby-plsql", "~> 0.8"

toddwf commented 1 year ago

I checked gem versions 7.0.1 and 7.0.0 and the issue exists in those versions as well, unfortunately.

y-takey commented 9 months ago

Are there any recommended solutions or workarounds for this issue?

toddwf commented 9 months ago

Are there any recommended solutions or workarounds for this issue?

This guy posted a monkeypatch that seems to work for me: https://gist.github.com/andynu/9522d16ab85fd4ec2c2c31903fbe249d

I do not know if this can be incorporated into a patch.

The other option is for every NUMBER((1) in your models, declare them as "attribute :, :integer" in that model. A bit verbose but it works.

andynu commented 4 months ago

This was fixed in #2301 and is available in oracle-enhanced_activerecord v7.0.3.