Skip to content

Commit 0aaaf96

Browse files
committed
formatted test
1 parent aa857ed commit 0aaaf96

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

jdbc-v2/src/test/java/com/clickhouse/jdbc/DataTypeTests.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,9 @@ public void testBooleanTypes() throws SQLException {
679679
@Test(groups = { "integration" })
680680
public void testArrayTypes() throws SQLException {
681681
runQuery("CREATE TABLE test_arrays (order Int8, "
682-
+ "array Array(Int8), arraystr Array(String), arraytuple Array(Tuple(Int8, String)), arraydate Array(Date)"
682+
+ "array Array(Int8), arraystr Array(String), "
683+
+ "arraytuple Array(Tuple(Int8, String)), "
684+
+ "arraydate Array(Date)"
683685
+ ") ENGINE = MergeTree ORDER BY ()");
684686

685687
// Insert random (valid) values
@@ -707,7 +709,7 @@ public void testArrayTypes() throws SQLException {
707709
arraydate[i] = Date.valueOf(LocalDate.now().plusDays(rand.nextInt(100)));
708710
}
709711

710-
// Insert random (valid) values
712+
// Insert using `Connection#createArrayOf`
711713
try (Connection conn = getConnection()) {
712714
try (PreparedStatement stmt = conn.prepareStatement("INSERT INTO test_arrays VALUES ( 1, ?, ?, ?, ?)")) {
713715
stmt.setArray(1, conn.createArrayOf("Int8", array));
@@ -718,6 +720,18 @@ public void testArrayTypes() throws SQLException {
718720
}
719721
}
720722

723+
// Insert using common java objects
724+
final String INSERT_SQL = "INSERT INTO test_arrays VALUES ( 1, ?, ?, ?, ?)";
725+
try (Connection conn = getConnection()) {
726+
try (PreparedStatement stmt = conn.prepareStatement(INSERT_SQL)) {
727+
stmt.setObject(1, array);
728+
stmt.setObject(2, arraystr);
729+
stmt.setObject(3, arraytuple);
730+
stmt.setObject(4, arraydate);
731+
stmt.executeUpdate();
732+
}
733+
}
734+
721735
// Check the results
722736
try (Connection conn = getConnection()) {
723737
try (Statement stmt = conn.createStatement()) {

0 commit comments

Comments
 (0)