Class: Sequel::JDBC::TypeConvertor
- Defined in:
- lib/sequel/adapters/jdbc.rb,
lib/sequel/adapters/jdbc/db2.rb,
lib/sequel/adapters/jdbc/oracle.rb,
lib/sequel/adapters/jdbc/postgresql.rb,
lib/sequel/adapters/jdbc/sqlanywhere.rb
Constant Summary collapse
- INSTANCE =
new
- MAP =
Hash.new(o.method(:Object))
- BASIC_MAP =
MAP.dup
- JAVA_BIG_DECIMAL_CONSTRUCTOR =
java.math.BigDecimal.java_class.constructor(Java::long).method(:new_instance)
Instance Method Summary collapse
- #DB2Clob(r, i) ⇒ Object
- #OracleDecimal(r, i) ⇒ Object
- #RubyBigDecimal(r, i) ⇒ Object
- #RubyBlob(r, i) ⇒ Object
- #RubyClob(r, i) ⇒ Object
- #RubyDate(r, i) ⇒ Object
-
#RubyPGArray(r, i) ⇒ Object
Return PostgreSQL array types as ruby Arrays instead of JDBC PostgreSQL driver-specific array type.
-
#RubyPGHstore(r, i) ⇒ Object
Return PostgreSQL hstore types as ruby Hashes instead of Java HashMaps.
- #RubyTime(r, i) ⇒ Object
- #RubyTimestamp(r, i) ⇒ Object
- #SqlAnywhereBoolean(r, i) ⇒ Object
Instance Method Details
#DB2Clob(r, i) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/sequel/adapters/jdbc/db2.rb', line 18 def DB2Clob(r, i) if v = r.getClob(i) v = v.getSubString(1, v.length) v = Sequel::SQL::Blob.new(v) if ::Sequel::DB2::use_clob_as_blob v end end |
#OracleDecimal(r, i) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/sequel/adapters/jdbc/oracle.rb', line 20 def OracleDecimal(r, i) if v = r.getBigDecimal(i) i = v.long_value if v == JAVA_BIG_DECIMAL_CONSTRUCTOR.call(i) i else BigDecimal.new(v.to_string) end end end |
#RubyBigDecimal(r, i) ⇒ Object
84 85 86 87 88 |
# File 'lib/sequel/adapters/jdbc.rb', line 84 def RubyBigDecimal(r, i) if v = r.getBigDecimal(i) BigDecimal.new(v.to_string) end end |
#RubyBlob(r, i) ⇒ Object
89 90 91 92 93 |
# File 'lib/sequel/adapters/jdbc.rb', line 89 def RubyBlob(r, i) if v = r.getBytes(i) Sequel::SQL::Blob.new(String.from_java_bytes(v)) end end |
#RubyClob(r, i) ⇒ Object
94 95 96 97 98 |
# File 'lib/sequel/adapters/jdbc.rb', line 94 def RubyClob(r, i) if v = r.getClob(i) v.getSubString(1, v.length) end end |
#RubyDate(r, i) ⇒ Object
74 75 76 77 78 |
# File 'lib/sequel/adapters/jdbc.rb', line 74 def RubyDate(r, i) if v = r.getDate(i) Date.civil(v.getYear + 1900, v.getMonth + 1, v.getDate) end end |
#RubyPGArray(r, i) ⇒ Object
Return PostgreSQL array types as ruby Arrays instead of JDBC PostgreSQL driver-specific array type. Only used if the database does not have a conversion proc for the type.
22 23 24 25 26 |
# File 'lib/sequel/adapters/jdbc/postgresql.rb', line 22 def RubyPGArray(r, i) if v = r.getArray(i) v.array.to_ary end end |
#RubyPGHstore(r, i) ⇒ Object
Return PostgreSQL hstore types as ruby Hashes instead of Java HashMaps. Only used if the database does not have a conversion proc for the type.
31 32 33 34 35 |
# File 'lib/sequel/adapters/jdbc/postgresql.rb', line 31 def RubyPGHstore(r, i) if v = r.getObject(i) v.to_hash end end |
#RubyTime(r, i) ⇒ Object
69 70 71 72 73 |
# File 'lib/sequel/adapters/jdbc.rb', line 69 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
79 80 81 82 83 |
# File 'lib/sequel/adapters/jdbc.rb', line 79 def RubyTimestamp(r, i) if v = r.getTimestamp(i) Sequel.([v.getYear + 1900, v.getMonth + 1, v.getDate, v.getHours, v.getMinutes, v.getSeconds, v.getNanos]) end end |
#SqlAnywhereBoolean(r, i) ⇒ Object
32 33 34 35 36 |
# File 'lib/sequel/adapters/jdbc/sqlanywhere.rb', line 32 def SqlAnywhereBoolean(r, i) if v = Short(r, i) v != 0 end end |