From cc83b585b47ab23549138f91f6226fe8d5240542 Mon Sep 17 00:00:00 2001 From: LiuNeng <1398775315@qq.com> Date: Mon, 13 Dec 2021 11:31:52 +0800 Subject: [PATCH] Fix DataTypeDate#deserializeBinaryBulk (#391) --- .../housepower/jdbc/data/type/DataTypeDate.java | 3 +-- .../housepower/jdbc/QueryComplexTypeITest.java | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/clickhouse-native-jdbc/src/main/java/com/github/housepower/jdbc/data/type/DataTypeDate.java b/clickhouse-native-jdbc/src/main/java/com/github/housepower/jdbc/data/type/DataTypeDate.java index 04f32e68..5fa07e12 100644 --- a/clickhouse-native-jdbc/src/main/java/com/github/housepower/jdbc/data/type/DataTypeDate.java +++ b/clickhouse-native-jdbc/src/main/java/com/github/housepower/jdbc/data/type/DataTypeDate.java @@ -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; } diff --git a/clickhouse-native-jdbc/src/test/java/com/github/housepower/jdbc/QueryComplexTypeITest.java b/clickhouse-native-jdbc/src/test/java/com/github/housepower/jdbc/QueryComplexTypeITest.java index ac5451f6..ba2eb34f 100644 --- a/clickhouse-native-jdbc/src/test/java/com/github/housepower/jdbc/QueryComplexTypeITest.java +++ b/clickhouse-native-jdbc/src/test/java/com/github/housepower/jdbc/QueryComplexTypeITest.java @@ -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; @@ -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 -> {