提交 edeb2c89 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Add missing type conversions to extractObjectOfType()

上级 26000a01
......@@ -3928,9 +3928,9 @@ public class JdbcResultSet extends TraceObject implements ResultSet, JdbcResultS
return type.cast(value == ValueNull.INSTANCE
? null : new JdbcSQLXML(conn, value, JdbcLob.State.WITH_VALUE, id));
} else if (type == TimestampWithTimeZone.class) {
return type.cast(value.getObject());
return type.cast(value.convertTo(Value.TIMESTAMP_TZ).getObject());
} else if (DataType.isGeometryClass(type)) {
return type.cast(value.getObject());
return type.cast(value.convertTo(Value.GEOMETRY).getObject());
} else if (type == LocalDateTimeUtils.LOCAL_DATE) {
return type.cast(LocalDateTimeUtils.valueToLocalDate(value));
} else if (type == LocalDateTimeUtils.LOCAL_TIME) {
......
......@@ -149,6 +149,13 @@ public class TestSpatial extends TestDb {
new Coordinate(2, 2),
new Coordinate(1, 1) });
assertTrue(polygon.equals(rs.getObject(2)));
rs.close();
rs = stat.executeQuery("select id, cast(polygon as varchar) from test");
assertTrue(rs.next());
assertEquals(1, rs.getInt(1));
assertEquals("POLYGON ((1 1, 1 2, 2 2, 1 1))", rs.getObject(2));
assertTrue(polygon.equals(rs.getObject(2, Geometry.class)));
rs.close();
rs = stat.executeQuery("select * from test where polygon = " +
"'POLYGON ((1 1, 1 2, 2 2, 1 1))'");
......
......@@ -69,7 +69,8 @@ public class TestTimeStampWithTimeZone extends TestDb {
assertEquals(1, ts.getMonth());
assertEquals(1, ts.getDay());
assertEquals(15, ts.getTimeZoneOffsetMins());
assertEquals(new TimestampWithTimeZone(1008673L, 43200000000000L, (short) 15), ts);
TimestampWithTimeZone firstExpected = new TimestampWithTimeZone(1008673L, 43200000000000L, (short) 15);
assertEquals(firstExpected, ts);
if (LocalDateTimeUtils.isJava8DateApiPresent()) {
assertEquals("1970-01-01T12:00+00:15", rs.getObject(1,
LocalDateTimeUtils.OFFSET_DATE_TIME).toString());
......@@ -125,6 +126,11 @@ public class TestTimeStampWithTimeZone extends TestDb {
assertEquals(2014, columnType);
rs.close();
rs = stat.executeQuery("select cast(t1 as varchar) from test");
assertTrue(rs.next());
assertEquals(firstExpected, rs.getObject(1, TimestampWithTimeZone.class));
stat.close();
conn.close();
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论