Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps): bump versions-maven-plugin from 2.15.0 to 2.16.0 #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.15.0</version>
<version>2.16.0</version>
</plugin>

<plugin>
Expand Down
12 changes: 9 additions & 3 deletions src/main/java/org/sqlite/jdbc4/JDBC4ResultSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,9 @@ public <T> T getObject(int columnIndex, Class<T> type) throws SQLException {
if (type == Timestamp.class) return type.cast(getTimestamp(columnIndex));
if (type == LocalDate.class) {
try {
return type.cast(getDate(columnIndex).toLocalDate());
Date date = getDate(columnIndex);
if (date != null) return type.cast(date.toLocalDate());
else return null;
} catch (SQLException sqlException) {
// If the FastDateParser failed, try parse it with LocalDate.
// It's a workaround for a value like '2022-12-1' (i.e no time presents).
Expand All @@ -333,15 +335,19 @@ public <T> T getObject(int columnIndex, Class<T> type) throws SQLException {
}
if (type == LocalTime.class) {
try {
return type.cast(getTime(columnIndex).toLocalTime());
Time time = getTime(columnIndex);
if (time != null) return type.cast(time.toLocalTime());
else return null;
} catch (SQLException sqlException) {
// If the FastDateParser failed, try parse it with LocalTime.
// It's a workaround for a value like '11:22:22' (i.e no date presents).
return type.cast(LocalTime.parse(getString(columnIndex)));
}
}
if (type == LocalDateTime.class) {
return type.cast(getTimestamp(columnIndex).toLocalDateTime());
Timestamp timestamp = getTimestamp(columnIndex);
if (timestamp != null) return type.cast(timestamp.toLocalDateTime());
else return null;
}

int columnType = safeGetColumnType(markCol(columnIndex));
Expand Down
6 changes: 6 additions & 0 deletions src/test/java/org/sqlite/ResultSetTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ void testJdk8AddedDateTimeObjects() throws SQLException {
stat.executeUpdate("insert into datetime_test values ('2021-11-09 11:20:58')");
stat.executeUpdate("insert into datetime_test values ('2021-11-09')");
stat.executeUpdate("insert into datetime_test values ('11:20:58')");
stat.executeUpdate("insert into datetime_test values (NULL)");

ResultSet rs = stat.executeQuery("select * from datetime_test");

Expand All @@ -349,6 +350,11 @@ void testJdk8AddedDateTimeObjects() throws SQLException {

rs.next();
assertThat(rs.getObject(1, LocalTime.class)).isEqualTo(LocalTime.of(11, 20, 58));

rs.next();
assertThat(rs.getObject(1, LocalDate.class)).isNull();
assertThat(rs.getObject(1, LocalTime.class)).isNull();
assertThat(rs.getObject(1, LocalDateTime.class)).isNull();
}

@Test
Expand Down
Loading