Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
toddwf opened this issue Jan 6, 2023 · 4 comments
Open

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

toddwf opened this issue Jan 6, 2023 · 4 comments

Comments

@toddwf
Copy link

toddwf commented Jan 6, 2023

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
Copy link
Author

toddwf commented Jan 9, 2023

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

@y-takey
Copy link

y-takey commented Oct 10, 2023

Are there any recommended solutions or workarounds for this issue?

@toddwf
Copy link
Author

toddwf commented Oct 20, 2023

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 :<col_name>, :integer" in that model. A bit verbose but it works.

@andynu
Copy link
Contributor

andynu commented Mar 19, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants