module ArJdbc::Oracle::Column::Cast
Public Instance Methods
guess_date_or_time(value)
click to toggle source
@private
# File lib/arjdbc/oracle/column.rb, line 116 def guess_date_or_time(value) return value if value.is_a? Date ( value && value.hour == 0 && value.min == 0 && value.sec == 0 ) ? Date.new(value.year, value.month, value.day) : value end
string_to_time(string)
click to toggle source
@override
Calls superclass method
# File lib/arjdbc/oracle/column.rb, line 107 def string_to_time(string) return string unless string.is_a?(String) return nil if string.empty? return Time.now if string.index('CURRENT') == 0 # TODO seems very wrong super(string) end
value_to_boolean(value)
click to toggle source
Convert a value to a boolean.
# File lib/arjdbc/oracle/column.rb, line 94 def value_to_boolean(value) # NOTE: Oracle JDBC meta-data gets us DECIMAL for NUMBER(1) values # thus we're likely to get a column back as BigDecimal (e.g. 1.0) if value.is_a?(String) value.blank? ? nil : value == '1' elsif value.is_a?(Numeric) value.to_i == 1 # <BigDecimal:7b5bfe,'0.1E1',1(4)> else !! value end end