Skip to content
Permalink
Browse files

add checks for null results (#1616)

  • Loading branch information
davecramer committed Nov 25, 2019
1 parent 7f1752a commit 69320c7a7dc065f44db5ddeec8143c606298b382
@@ -67,6 +67,7 @@ public void testGetDate() throws SQLException {
assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL("testdate", "'3456-01-01'")));
assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL("testdate", "'0101-01-01 BC'")));


/* dateTest() contains all of the tests */
dateTest();

@@ -338,6 +338,36 @@ public void testGetDate() throws SQLException {
}
}

@Test
public void testGetNullDate() throws SQLException {
Statement stmt = conn.createStatement();
stmt.executeUpdate(TestUtil.insertSQL("table1","date_column","NULL"));

ResultSet rs = stmt.executeQuery(TestUtil.selectSQL("table1", "date_column"));
try {
assertTrue(rs.next());
Date date = rs.getObject(1,Date.class);
assertTrue(rs.wasNull());
} finally {
rs.close();
}
}

@Test
public void testGetNullTimestamp() throws SQLException {
Statement stmt = conn.createStatement();
stmt.executeUpdate(TestUtil.insertSQL("table1","timestamp_without_time_zone_column","NULL"));

ResultSet rs = stmt.executeQuery(TestUtil.selectSQL("table1", "timestamp_without_time_zone_column"));
try {
assertTrue(rs.next());
java.util.Date ts = rs.getObject(1, java.util.Date.class);
assertTrue(rs.wasNull());
} finally {
rs.close();
}
}

/**
* Test the behavior getObject for time columns.
*/

0 comments on commit 69320c7

Please sign in to comment.
You can’t perform that action at this time.