提交 3e5d6415 authored 作者: Noel Grandin's avatar Noel Grandin 提交者: GitHub

Merge pull request #496 from marschall/bind-timestamp-with-time-zone

TimestampWithTimeZone can not be bound
......@@ -1121,6 +1121,8 @@ public class DataType {
return LocalDateTimeUtils.localDateTimeToValue(x);
} else if (LocalDateTimeUtils.isOffsetDateTime(x.getClass())) {
return LocalDateTimeUtils.offsetDateTimeToValue(x);
} else if (x instanceof TimestampWithTimeZone) {
return ValueTimestampTimeZone.get((TimestampWithTimeZone) x);
} else {
if (JdbcUtils.customDataTypesHandler != null) {
return JdbcUtils.customDataTypesHandler.getValue(type, x,
......
......@@ -6,13 +6,16 @@
package org.h2.test.unit;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import org.h2.api.TimestampWithTimeZone;
import org.h2.test.TestBase;
import org.h2.util.LocalDateTimeUtils;
import org.h2.value.Value;
import org.h2.value.ValueTimestampTimeZone;
/**
......@@ -35,6 +38,7 @@ public class TestTimeStampWithTimeZone extends TestBase {
test2();
test3();
test4();
test5();
testOrder();
deleteDb(getTestName());
}
......@@ -139,6 +143,31 @@ public class TestTimeStampWithTimeZone extends TestBase {
assertEquals(c, 0);
}
private void test5() throws SQLException {
Connection conn = getConnection(getTestName());
Statement stat = conn.createStatement();
stat.execute("create table test5(id identity, t1 timestamp with time zone)");
stat.execute("insert into test5(t1) values('2016-09-24 00:00:00.000000001+00:01')");
stat.execute("insert into test5(t1) values('2017-04-20 00:00:00.000000001+00:01')");
PreparedStatement preparedStatement = conn.prepareStatement("select id"
+ " from test5"
+ " where (t1 < ?)");
Value value = ValueTimestampTimeZone.parse("2016-12-24 00:00:00.000000001+00:01");
preparedStatement.setObject(1, value.getObject());
ResultSet rs = preparedStatement.executeQuery();
assertTrue(rs.next());
assertEquals(1, rs.getInt(1));
assertFalse(rs.next());
rs.close();
preparedStatement.close();
stat.close();
conn.close();
}
private void testOrder() throws SQLException {
Connection conn = getConnection(getTestName());
Statement stat = conn.createStatement();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论