Skip to content

Commit 96a3044

Browse files
committed
added out of index test for parameter metadata
1 parent 7eb28e5 commit 96a3044

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

jdbc-v2/src/main/java/com/clickhouse/jdbc/metadata/ParameterMetaDataImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ public String getParameterClassName(int param) throws SQLException {
127127
@Override
128128
public int getParameterMode(int param) throws SQLException {
129129
checkParamIndex(param);
130+
// only in parameter mode IN is supported by prepared statement
131+
// other modes are designed for callable statements
130132
return parameterModeIn;
131133
}
132134
}

jdbc-v2/src/test/java/com/clickhouse/jdbc/metadata/ParameterMetaDataImplTest.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
import java.sql.SQLException;
66
import java.sql.Types;
77

8-
import static org.testng.Assert.*;
8+
import static org.testng.Assert.assertEquals;
9+
import static org.testng.Assert.assertFalse;
10+
import static org.testng.Assert.assertThrows;
911

1012

1113
public class ParameterMetaDataImplTest {
@@ -81,4 +83,17 @@ public void testGetParameterMode() throws SQLException {
8183
assertThrows(() -> metaData.getParameterMode(0));
8284
assertThrows(() -> metaData.getParameterMode(2));
8385
}
86+
87+
@Test(groups = {"integration"})
88+
public void testColumnOutOfIndex() throws SQLException {
89+
ParameterMetaDataImpl metaData = new ParameterMetaDataImpl(1);
90+
int indexAfterLastColumn = 2;
91+
assertThrows(SQLException.class, () -> metaData.getParameterMode(indexAfterLastColumn));
92+
assertThrows(SQLException.class, () -> metaData.getParameterType(indexAfterLastColumn));
93+
assertThrows(SQLException.class, () -> metaData.getScale(indexAfterLastColumn));
94+
assertThrows(SQLException.class, () -> metaData.getPrecision(indexAfterLastColumn));
95+
assertThrows(SQLException.class, () -> metaData.getParameterClassName(indexAfterLastColumn));
96+
assertThrows(SQLException.class, () -> metaData.isNullable(indexAfterLastColumn));
97+
assertThrows(SQLException.class, () -> metaData.isSigned(indexAfterLastColumn));
98+
}
8499
}

0 commit comments

Comments
 (0)