Skip to content

Commit

Permalink
Fix DataTypeDate#deserializeBinaryBulk (#391)
Browse files Browse the repository at this point in the history
  • Loading branch information
liuneng1994 authored Dec 13, 2021
1 parent 033c701 commit cc83b58
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ public Object deserializeBinary(BinaryDeserializer deserializer) throws IOExcept
public Object[] deserializeBinaryBulk(int rows, BinaryDeserializer deserializer) throws IOException {
LocalDate[] data = new LocalDate[rows];
for (int row = 0; row < rows; row++) {
short epochDay = deserializer.readShort();
data[row] = LocalDate.ofEpochDay(epochDay);
data[row] = (LocalDate) deserializeBinary(deserializer);
}
return data;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.junit.jupiter.api.Test;

import java.sql.Array;
import java.sql.Date;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.Struct;
Expand Down Expand Up @@ -252,6 +253,20 @@ public void successfullyNullableNothing() throws Exception {
});
}

@Test
public void successfullyDateArrayColumn() throws Exception {
withNewConnection(connect -> {
Statement statement = connect.createStatement();
ResultSet rs = statement.executeQuery("SELECT array(toDate('2105-12-30')) AS value, toTypeName(value)");

assertTrue(rs.next());
Object[] values = (Object[]) rs.getArray(1).getArray();
assertEquals(Date.valueOf("2105-12-30"), Date.valueOf((LocalDate) values[0]));
assertEquals("Array(Date)", rs.getString(2));
});
}


@Test
public void successfullyTuple() throws Exception {
withNewConnection(connection -> {
Expand Down

0 comments on commit cc83b58

Please sign in to comment.