Class: Sequel::JDBC::TypeConvertor

Inherits:
Object
  • Object
show all
Defined in:
lib/sequel/adapters/jdbc.rb

Constant Summary collapse

INSTANCE =
new
MAP =
Hash.new(o.method(:Object))
BASIC_MAP =
MAP.dup

Instance Method Summary collapse

Instance Method Details

#RubyBigDecimal(r, i) ⇒ Object



85
86
87
88
89
# File 'lib/sequel/adapters/jdbc.rb', line 85

def RubyBigDecimal(r, i)
  if v = r.getBigDecimal(i)
    BigDecimal.new(v.to_string)
  end
end

#RubyBlob(r, i) ⇒ Object



90
91
92
93
94
# File 'lib/sequel/adapters/jdbc.rb', line 90

def RubyBlob(r, i)
  if v = r.getBytes(i)
    Sequel::SQL::Blob.new(String.from_java_bytes(v))
  end
end

#RubyClob(r, i) ⇒ Object



95
96
97
98
99
# File 'lib/sequel/adapters/jdbc.rb', line 95

def RubyClob(r, i)
  if v = r.getClob(i)
    v.getSubString(1, v.length)
  end
end

#RubyDate(r, i) ⇒ Object



75
76
77
78
79
# File 'lib/sequel/adapters/jdbc.rb', line 75

def RubyDate(r, i)
  if v = r.getDate(i)
    Date.civil(v.getYear + 1900, v.getMonth + 1, v.getDate)
  end
end

#RubyTime(r, i) ⇒ Object



70
71
72
73
74
# File 'lib/sequel/adapters/jdbc.rb', line 70

def RubyTime(r, i)
  if v = r.getTime(i)
    Sequel.string_to_time("#{v.to_string}.#{sprintf('%03i', v.getTime.divmod(1000).last)}")
  end
end

#RubyTimestamp(r, i) ⇒ Object



80
81
82
83
84
# File 'lib/sequel/adapters/jdbc.rb', line 80

def RubyTimestamp(r, i)
  if v = r.getTimestamp(i)
    Sequel.database_to_application_timestamp([v.getYear + 1900, v.getMonth + 1, v.getDate, v.getHours, v.getMinutes, v.getSeconds, v.getNanos])
  end
end