Module: ArJdbc::Oracle::Column
- Included in:
- ActiveRecord::ConnectionAdapters::OracleColumn
- Defined in:
- lib/arjdbc/oracle/column.rb
Overview
Defined Under Namespace
Modules: Cast
Instance Method Summary collapse
- #extract_limit(sql_type) ⇒ Object
- #primary=(value) ⇒ Object
- #simplified_type(field_type) ⇒ Object
- #sql_type ⇒ Object
- #type_cast(value) ⇒ Object
- #type_cast_code(var_name) ⇒ Object
Instance Method Details
#extract_limit(sql_type) ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/arjdbc/oracle/column.rb', line 49 def extract_limit(sql_type) case sql_type when /^(clob|date)/i then nil when /^xml/i then nil else super end end |
#primary=(value) ⇒ Object
17 18 19 20 |
# File 'lib/arjdbc/oracle/column.rb', line 17 def primary=(value) super @type = :integer if value && @sql_type =~ /^NUMBER$/i end |
#simplified_type(field_type) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/arjdbc/oracle/column.rb', line 57 def simplified_type(field_type) case field_type when /char/i then :string when /float|double/i then :float when /int/i then :integer when /^number\(1\)$/i then Oracle.emulate_booleans? ? :boolean : :integer when /^num|dec|real/i then extract_scale(field_type) == 0 ? :integer : :decimal # Oracle TIMESTAMP stores the date and time to up to 9 digits of sub-second precision when /TIMESTAMP/i then :timestamp # Oracle DATE stores the date and time to the second when /DATE|TIME/i then :datetime when /CLOB/i then :text when /BLOB/i then :binary when /XML/i then :xml else super end end |
#sql_type ⇒ Object
43 44 45 |
# File 'lib/arjdbc/oracle/column.rb', line 43 def sql_type (@sql_type || '').start_with?('XMLTYPE') ? 'XMLTYPE' : @sql_type end |
#type_cast(value) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/arjdbc/oracle/column.rb', line 22 def type_cast(value) return nil if value.nil? case type when :datetime then self.class.string_to_time(value) when :timestamp then self.class.string_to_time(value) when :boolean then self.class.value_to_boolean(value) else super end end |
#type_cast_code(var_name) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/arjdbc/oracle/column.rb', line 33 def type_cast_code(var_name) case type when :datetime then "#{self.class.name}.string_to_time(#{var_name})" when :timestamp then "#{self.class.name}.string_to_time(#{var_name})" when :boolean then "#{self.class.name}.value_to_boolean(#{var_name})" else super end end |