Skip to content

Commit

Permalink
add checks for null results (#1616)
Browse files Browse the repository at this point in the history
  • Loading branch information
davecramer committed Nov 25, 2019
1 parent 7f1752a commit 69320c7
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
Expand Up @@ -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();

Expand Down
Expand Up @@ -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.
*/
Expand Down

0 comments on commit 69320c7

Please sign in to comment.