Hi All,
I'm running into an issue that I don't quite understand. I have a legacy Oracle DB. My primary key for my tables is called "sequence_no" and is defined as a NUMBER.
By default, that means that I'm getting paths like /user/207.0/edit. So I defined an initializer like so:
ActiveSupport.on_load(:active_record) do
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.class_eval do
# id columns and columns which are called sequence_no will always be converted to integers
self.emulate_integers_by_column_name = true
#This forces columns named 'sequence_no' or 'composite_id' to always be integers
#Otherwise, columns defined as NUMBER (not NUMBER(0)) will be considered decimals
def self.is_integer_column?(name, table_name = nil)
!!(name =~ /sequence_no|composite_id$/i)
end
end
end
(we also have to deal with columns named composite_id).
This works fantastically for all of my tables - except one. Here's a comparison of a column in a table that is fine, and one that isn't.
2.1.2 :027 > conn.columns('mytable2').find { |col|
col.name == 'sequence_no' }
=>
#<ActiveRecord::ConnectionAdapters::OracleEnhancedColumn:0x00000006d34888
@table_name="mytable2", @forced_column_type=nil, @virtual=false,
@returning_id=false, @name="sequence_no", @sql_type="NUMBER",
@null=false, @limit=nil, @precision=nil, @scale=nil, @type=:integer,
@default=nil, @default_function=nil, @primary=nil, @coder=nil,
@object_type=false>
2.1.2 :028 > conn.columns('mytable1').find { |col|
col.name == 'sequence_no' }
=> #<ActiveRecord::ConnectionAdapters::OracleEnhancedColumn:0x0000000320ba90 @table_name="mytable1", @forced_column_type=nil, @virtual=false, @returning_id=false, @name="sequence_no", @sql_type="NUMBER", @null=false, @limit=nil, @precision=nil, @scale=nil, @type=:decimal, @default=nil, @default_function=nil, @primary=nil, @coder=nil, @object_type=false>
So, on mytable2, the column is properly treated as an integer, but for mytable1, it isn't. I can't find any reason why this would be the case, and I'm stumped with what next steps I can do to troubleshoot this.
Has anyone run into something like this before? Any ideas I can try (or information I can provide?)
Thanks!
Cory