|
13 | 13 | import java.sql.ResultSetMetaData; |
14 | 14 | import java.sql.Statement; |
15 | 15 | import java.sql.Types; |
16 | | -import java.util.Arrays; |
17 | | -import java.util.GregorianCalendar; |
18 | | -import java.util.TimeZone; |
| 16 | +import java.util.*; |
19 | 17 |
|
20 | 18 | import static org.testng.Assert.assertEquals; |
21 | 19 | import static org.testng.Assert.assertFalse; |
@@ -580,4 +578,32 @@ void testClearParameters() throws Exception { |
580 | 578 | ps.execute(); |
581 | 579 | } |
582 | 580 | } |
| 581 | + |
| 582 | + @Test(groups = {"integration"}) |
| 583 | + void testWriteCollection() throws Exception { |
| 584 | + String sql = "insert into `test_issue_2329` (`id`, `name`, `age`, `arr`) values (?, ?, ?, ?)"; |
| 585 | + try (Connection conn = getJdbcConnection(); |
| 586 | + PreparedStatementImpl ps = (PreparedStatementImpl) conn.prepareStatement(sql)) { |
| 587 | + |
| 588 | + try (Statement stmt = conn.createStatement()) { |
| 589 | + stmt.execute("CREATE TABLE IF NOT EXISTS `test_issue_2329` (`id` Nullable(String), `name` Nullable(String), `age` Int32, `arr` Array(String)) ENGINE Memory;"); |
| 590 | + } |
| 591 | + |
| 592 | + Assert.assertEquals(ps.getParametersCount(), 4); |
| 593 | + Collection<String> arr = new ArrayList<String>(); |
| 594 | + ps.setString(1, "testId01"); |
| 595 | + ps.setString(2, "testName"); |
| 596 | + ps.setInt(3, 18); |
| 597 | + ps.setObject(4, arr); |
| 598 | + ps.execute(); |
| 599 | + |
| 600 | + try (Statement stmt = conn.createStatement()) { |
| 601 | + ResultSet rs = stmt.executeQuery("SELECT count(*) FROM `test_issue_2329`"); |
| 602 | + Assert.assertTrue(rs.next()); |
| 603 | + Assert.assertEquals(rs.getInt(1), 1); |
| 604 | + } |
| 605 | + } |
| 606 | + |
| 607 | + } |
| 608 | + |
583 | 609 | } |
0 commit comments