2

I have a legacy db on which I am building a rails 4 app.

In my db schema there are quite some fields that have single digit non boolean numbers (like 1-9) where a data-type of Number(1) was used. However, the oracle adapter automatically assumes that data-type number(1) is always boolean.

As can be seen in this question (rails3 aside 4 seems to be the same) Rails 3 datatypes?

I have tried to find an option for that on the o.e.a. github page however I could not find one.

A pointer in the right direction would be great.

Community
  • 1
  • 1
mahatmanich
  • 10,791
  • 5
  • 63
  • 82
  • 1
    I don't think that is a correct behaviour - to presume that every one-number column is a boolean. I'd say go ahead and create an issue on their github page. I'm sure they'll at least give you a workaround. – Magnuss Oct 04 '13 at 12:08
  • Good to try: https://github.com/rsim/oracle-enhanced/tree/rails4 – Emyl Oct 04 '13 at 14:01
  • @Magnuss actually it is default behavior https://github.com/rsim/oracle-enhanced/issues/338 – mahatmanich Oct 04 '13 at 14:33

1 Answers1

2

From https://github.com/rsim/oracle-enhanced/issues/338

This is a default behavior also you can disable if you want.

https://github.com/rsim/oracle-enhanced/blob/master/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb#L109-L117

  ##
  # :singleton-method:
  # By default, the OracleEnhancedAdapter will consider all columns of type <tt>NUMBER(1)</tt>
  # as boolean. If you wish to disable this emulation you can add the following line
  # to your initializer file:
  #
  #   ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans = false
  cattr_accessor :emulate_booleans
  self.emulate_booleans = true
mahatmanich
  • 10,791
  • 5
  • 63
  • 82