Bug when NUMERIC type has a SCALE of nil #165

Closed
wants to merge 2 commits into
from
@@ -870,7 +870,7 @@ def write_lobs(table_name, klass, attributes) #:nodoc:
if is_with_cpk
id = klass.primary_key.map {|pk| attributes[pk.to_s] }
else
- id = quote(attributes[klass.primary_key])
+ id = quote(attributes[klass.primary_key.to_s]) #fix or else it can't find it if attributes are quoted and this is a symbol
end
klass.columns.select { |col| col.sql_type =~ /LOB$/i }.each do |col|
value = attributes[col.name]
@@ -62,13 +62,18 @@ def comment
private
+ def scale_present?(field_type)
+ scale = extract_scale(field_type)
+ return scale.nil? || scale == 0
+ end
+
def simplified_type(field_type)
forced_column_type ||
case field_type
when /decimal|numeric|number/i
if OracleEnhancedAdapter.emulate_booleans && field_type == 'NUMBER(1)'
:boolean
- elsif extract_scale(field_type) == 0 ||
+ elsif scale_present?(field_type) ||
# if column name is ID or ends with _ID
OracleEnhancedAdapter.emulate_integers_by_column_name && OracleEnhancedAdapter.is_integer_column?(name, table_name)
:integer