Module: OracleEnhancedColumnWithXmltype::InstanceMethods

Defined in:
lib/oracle_enhanced_plus_xmltype/oracle_enhanced_column_with_xmltype.rb

Instance Method Summary collapse

Instance Method Details

#simplified_type(field_type) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/oracle_enhanced_plus_xmltype/oracle_enhanced_column_with_xmltype.rb', line 9

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 ||
      # if column name is ID or ends with _ID
      OracleEnhancedAdapter.emulate_integers_by_column_name && OracleEnhancedAdapter.is_integer_column?(name, table_name)
      :integer
    else
      :decimal
    end
  when /raw/i
    :raw
  when /char/i
    if OracleEnhancedAdapter.emulate_booleans_from_strings &&
      OracleEnhancedAdapter.is_boolean_column?(name, field_type, table_name)
      :boolean
    else
      :string
    end
  when /date/i
    if OracleEnhancedAdapter.emulate_dates_by_column_name && OracleEnhancedAdapter.is_date_column?(name, table_name)
      :date
    else
      :datetime
    end
  when /timestamp/i
    :timestamp
  when /time/i
    :datetime
  when /xmltype/i
    :xmltype
  else
    super
  end
end