Skip to content

Commit 2d7a98f

Browse files
author
Paultagoras
committed
Updating to address some seen issues/bugs
1 parent d5d1255 commit 2d7a98f

File tree

5 files changed

+109
-74
lines changed

5 files changed

+109
-74
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,12 @@ public ClickHouseGeoMultiPolygonValue getGeoMultiPolygon(int index) {
618618

619619
@Override
620620
public <T> List<T> getList(int index) {
621-
return readValue(index);
621+
try {
622+
BinaryStreamReader.ArrayValue array = readValue(index);
623+
return array.asList();
624+
} catch (ClassCastException e) {
625+
throw new ClientException("Column is not of array type", e);
626+
}
622627
}
623628

624629
@Override

jdbc-v2/src/main/java/com/clickhouse/jdbc/ConnectionImpl.java

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,13 @@ public JdbcConfiguration getJdbcConfig() {
115115
@Override
116116
public Statement createStatement() throws SQLException {
117117
checkOpen();
118-
return new StatementImpl(this);
118+
return createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.CLOSE_CURSORS_AT_COMMIT);
119119
}
120120

121121
@Override
122122
public PreparedStatement prepareStatement(String sql) throws SQLException {
123123
checkOpen();
124-
return new PreparedStatementImpl(this, sql);
124+
return prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.CLOSE_CURSORS_AT_COMMIT);
125125
}
126126

127127
@Override
@@ -240,14 +240,13 @@ public void clearWarnings() throws SQLException {
240240
@Override
241241
public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException {
242242
checkOpen();
243-
//TODO: Should this be a silent ignore?
244-
throw new SQLFeatureNotSupportedException("Statement with resultSetType and resultSetConcurrency override not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
243+
return createStatement(resultSetType, resultSetConcurrency, ResultSet.CLOSE_CURSORS_AT_COMMIT);
245244
}
246245

247246
@Override
248247
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
249248
checkOpen();
250-
throw new SQLFeatureNotSupportedException("PreparedStatement with resultSetType and resultSetConcurrency override not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
249+
return prepareStatement(sql, resultSetType, resultSetConcurrency, ResultSet.CLOSE_CURSORS_AT_COMMIT);
251250
}
252251

253252
@Override
@@ -309,15 +308,13 @@ public void releaseSavepoint(Savepoint savepoint) throws SQLException {
309308
@Override
310309
public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
311310
checkOpen();
312-
//TODO: Should this be a silent ignore?
313-
throw new SQLFeatureNotSupportedException("Statement with resultSetType, resultSetConcurrency, and resultSetHoldability override not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
311+
return new StatementImpl(this);
314312
}
315313

316314
@Override
317315
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
318316
checkOpen();
319-
//TODO: Should this be a silent ignore?
320-
throw new SQLFeatureNotSupportedException("PreparedStatement with resultSetType, resultSetConcurrency, and resultSetHoldability override not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
317+
return new PreparedStatementImpl(this, sql);
321318
}
322319

323320
@Override
@@ -330,21 +327,33 @@ public CallableStatement prepareCall(String sql, int resultSetType, int resultSe
330327
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException {
331328
checkOpen();
332329
//TODO: Should this be supported?
333-
throw new SQLFeatureNotSupportedException("prepareStatement(String sql, int autoGeneratedKeys) not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
330+
if (!config.isIgnoreUnsupportedRequests()) {
331+
throw new SQLFeatureNotSupportedException("prepareStatement(String sql, int autoGeneratedKeys) not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
332+
} else {
333+
return prepareStatement(sql);
334+
}
334335
}
335336

336337
@Override
337338
public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException {
338339
checkOpen();
339340
//TODO: Should this be supported?
340-
throw new SQLFeatureNotSupportedException("prepareStatement(String sql, int[] columnIndexes) not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
341+
if (!config.isIgnoreUnsupportedRequests()) {
342+
throw new SQLFeatureNotSupportedException("prepareStatement(String sql, int[] columnIndexes) not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
343+
} else {
344+
return prepareStatement(sql);
345+
}
341346
}
342347

343348
@Override
344349
public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException {
345350
checkOpen();
346351
//TODO: Should this be supported?
347-
throw new SQLFeatureNotSupportedException("prepareStatement(String sql, String[] columnNames) not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
352+
if (!config.isIgnoreUnsupportedRequests()) {
353+
throw new SQLFeatureNotSupportedException("prepareStatement(String sql, String[] columnNames) not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
354+
} else {
355+
return prepareStatement(sql);
356+
}
348357
}
349358

350359
@Override

0 commit comments

Comments
 (0)