Module: ArJdbc::Oracle::Column

Defined in:
lib/arjdbc/oracle/adapter.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.guess_date_or_time(value) ⇒ Object



81
82
83
84
85
# File 'lib/arjdbc/oracle/adapter.rb', line 81

def self.guess_date_or_time(value)
  return value if Date === value
  (value && value.hour == 0 && value.min == 0 && value.sec == 0) ?
  Date.new(value.year, value.month, value.day) : value
end

.string_to_time(string, klass) ⇒ Object



76
77
78
79
# File 'lib/arjdbc/oracle/adapter.rb', line 76

def self.string_to_time(string, klass)
  time = klass.string_to_time(string)
  guess_date_or_time(time)
end

Instance Method Details

#extract_limit(sql_type) ⇒ Object



61
62
63
64
65
66
# File 'lib/arjdbc/oracle/adapter.rb', line 61

def extract_limit(sql_type)
  case sql_type
  when /^(clob|date)/i; nil
  else super
  end
end

#primary=(val) ⇒ Object



45
46
47
48
49
50
# File 'lib/arjdbc/oracle/adapter.rb', line 45

def primary=(val)
  super
  if val && @sql_type =~ /^NUMBER$/i
    @type = :integer
  end
end

#type_cast(value) ⇒ Object



52
53
54
55
56
57
58
59
# File 'lib/arjdbc/oracle/adapter.rb', line 52

def type_cast(value)
  return nil if value.nil?
  case type
  when :datetime then ArJdbc::Oracle::Column.string_to_time(value, self.class)
  else
    super
  end
end

#type_cast_code(var_name) ⇒ Object



68
69
70
71
72
73
74
# File 'lib/arjdbc/oracle/adapter.rb', line 68

def type_cast_code(var_name)
  case type
  when :datetime  then "ArJdbc::Oracle::Column.string_to_time(#{var_name}, self.class)"
  else
    super
  end
end