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



85
86
87
88
89
# File 'lib/arjdbc/oracle/adapter.rb', line 85

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



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

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



65
66
67
68
69
70
# File 'lib/arjdbc/oracle/adapter.rb', line 65

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

#primary=(val) ⇒ Object



49
50
51
52
53
54
# File 'lib/arjdbc/oracle/adapter.rb', line 49

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

#type_cast(value) ⇒ Object



56
57
58
59
60
61
62
63
# File 'lib/arjdbc/oracle/adapter.rb', line 56

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



72
73
74
75
76
77
78
# File 'lib/arjdbc/oracle/adapter.rb', line 72

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