|
1 | 1 | package com.clickhouse.jdbc.internal; |
2 | 2 |
|
| 3 | +import com.clickhouse.client.api.DataTypeUtils; |
3 | 4 | import com.clickhouse.client.api.data_formats.internal.BinaryStreamReader; |
4 | 5 | import com.clickhouse.client.api.data_formats.internal.InetAddressConverter; |
5 | 6 | import com.clickhouse.data.ClickHouseColumn; |
@@ -294,10 +295,10 @@ public static Object convert(Object value, Class<?> type, ClickHouseColumn colum |
294 | 295 | return new Array(column, arrayValue.getArrayOfObjects()); |
295 | 296 | } |
296 | 297 |
|
297 | | - return convertObject(value, type); |
| 298 | + return convertObject(value, type, column); |
298 | 299 | } |
299 | 300 |
|
300 | | - public static Object convertObject(Object value, Class<?> type) throws SQLException { |
| 301 | + public static Object convertObject(Object value, Class<?> type, ClickHouseColumn column) throws SQLException { |
301 | 302 | if (value == null || type == null) { |
302 | 303 | return value; |
303 | 304 | } |
@@ -343,7 +344,8 @@ public static Object convertObject(Object value, Class<?> type) throws SQLExcept |
343 | 344 | } else if (type == Time.class && value instanceof Integer) { // Time |
344 | 345 | return new Time((Integer) value * 1000L); |
345 | 346 | } else if (type == Time.class && value instanceof Long) { // Time64 |
346 | | - return new Time((Long) value / 1_000_000); |
| 347 | + Instant instant = DataTypeUtils.instantFromTime64Integer(column.getScale(), (Long) value); |
| 348 | + return new Time(instant.getEpochSecond() * 1000L + instant.getNano() / 1_000_000); |
347 | 349 | } else if (type == Inet4Address.class && value instanceof Inet6Address) { |
348 | 350 | // Convert Inet6Address to Inet4Address |
349 | 351 | return InetAddressConverter.convertToIpv4((InetAddress) value); |
|
0 commit comments