Skip to content

Commit e722fd9

Browse files
committed
fixed columnIndex check
1 parent 5ef9c40 commit e722fd9

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/ValueConverters.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,11 @@ public ValueConverters() {
104104
stringMapBuilder.put(URL.class, this::convertStringToURL);
105105
mapBuilder.put(String.class, stringMapBuilder.build());
106106

107-
mapBuilder.put(java.sql.Date.class, ImmutableMap.of(java.sql.Date.class, this::conveSqlDateToSqlDate,
107+
mapBuilder.put(java.sql.Date.class, ImmutableMap.of(java.sql.Date.class, this::convertSqlDateToSqlDate,
108108
String.class, this::convertDateToString));
109-
mapBuilder.put(Time.class, ImmutableMap.of(Time.class, this::conveSqlTimeToSqlTime,
109+
mapBuilder.put(Time.class, ImmutableMap.of(Time.class, this::convertSqlTimeToSqlTime,
110110
String.class, this::convertTimeToString));
111-
mapBuilder.put(Timestamp.class, ImmutableMap.of(Timestamp.class, this::conveSqlTimestampToSqlTimestamp,
111+
mapBuilder.put(Timestamp.class, ImmutableMap.of(Timestamp.class, this::convertSqlTimestampToSqlTimestamp,
112112
String.class, this::convertTimestampToString));
113113

114114
classConverters = mapBuilder.build();
@@ -214,15 +214,15 @@ public BigDecimal convertNumberToBigDecimal(Object value) {
214214
}
215215

216216
// Date & Time converters
217-
public java.sql.Date conveSqlDateToSqlDate(Object value) {
217+
public java.sql.Date convertSqlDateToSqlDate(Object value) {
218218
return (java.sql.Date) value;
219219
}
220220

221-
public Time conveSqlTimeToSqlTime(Object value) {
221+
public Time convertSqlTimeToSqlTime(Object value) {
222222
return (Time) value;
223223
}
224224

225-
public Timestamp conveSqlTimestampToSqlTimestamp(Object value) {
225+
public Timestamp convertSqlTimestampToSqlTimestamp(Object value) {
226226
return (Timestamp) value;
227227
}
228228

jdbc-v2/src/main/java/com/clickhouse/jdbc/internal/JdbcUtils.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import java.sql.SQLException;
1919
import java.sql.SQLType;
2020
import java.sql.Time;
21-
import java.sql.Time;
2221
import java.time.Instant;
2322
import java.time.LocalDate;
2423
import java.time.LocalDateTime;

jdbc-v2/src/main/java/com/clickhouse/jdbc/types/ArrayResultSet.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,14 @@ public class ArrayResultSet implements ResultSet {
5555
private final ClickHouseDataType componentDataType;
5656
private final Class<?> defaultClass;
5757
private final ClickHouseColumn column;
58+
private final int columnCount;
5859

5960
public ArrayResultSet(Object array, ClickHouseColumn column) {
6061
this.array = array;
6162
this.length = java.lang.reflect.Array.getLength(array);
6263
this.pos = -1;
6364
this.column = column;
65+
this.columnCount = 2; // INDEX, VALUE
6466

6567
List<ClickHouseColumn> nestedColumns = column.getNestedColumns();
6668
ClickHouseColumn valueColumn = column.getArrayNestedLevel() == 1 ? column.getArrayBaseColumn() : nestedColumns.get(0);
@@ -71,7 +73,7 @@ public ArrayResultSet(Object array, ClickHouseColumn column) {
7173
this.defaultClass = JdbcUtils.DATA_TYPE_CLASS_MAP.get(componentDataType);
7274
ValueConverters converters = new ValueConverters();
7375
indexConverterMap = converters.getConvertersForType(Integer.class);
74-
if (this.length > 1) {
76+
if (this.length > 0) {
7577
Class<?> itemClass = array.getClass().getComponentType();
7678
if (itemClass == null) {
7779
itemClass = java.lang.reflect.Array.get(array, 0).getClass();
@@ -93,7 +95,7 @@ public boolean next() throws SQLException {
9395
}
9496

9597
private void checkColumnIndex(int columnIndex) throws SQLException {
96-
if (columnIndex < 1 || columnIndex > length) {
98+
if (columnIndex < 1 || columnIndex > columnCount) {
9799
throw new SQLException("Invalid column index: " + columnIndex);
98100
}
99101
}

0 commit comments

Comments
 (0)