File tree Expand file tree Collapse file tree 2 files changed +27
-7
lines changed
main/java/com/clickhouse/jdbc
test/java/com/clickhouse/jdbc Expand file tree Collapse file tree 2 files changed +27
-7
lines changed Original file line number Diff line number Diff line change 4343import java .time .format .DateTimeFormatter ;
4444import java .time .format .DateTimeFormatterBuilder ;
4545import java .time .temporal .ChronoField ;
46- import java .util .ArrayList ;
47- import java .util .Arrays ;
48- import java .util .Calendar ;
49- import java .util .Collection ;
50- import java .util .Collections ;
51- import java .util .List ;
52- import java .util .Map ;
46+ import java .util .*;
5347
5448public class PreparedStatementImpl extends StatementImpl implements PreparedStatement , JdbcV2Wrapper {
5549 private static final Logger LOG = LoggerFactory .getLogger (PreparedStatementImpl .class );
@@ -659,6 +653,8 @@ private static String encodeObject(Object x) throws SQLException {
659653 }
660654 tupleString .append (")" );
661655 return tupleString .toString ();
656+ } else if (x instanceof UUID ) {
657+ return "'" + escapeString (((UUID ) x ).toString ()) + "'" ;
662658 }
663659
664660 return escapeString (x .toString ());//Escape single quotes
Original file line number Diff line number Diff line change 1616import java .util .Arrays ;
1717import java .util .GregorianCalendar ;
1818import java .util .TimeZone ;
19+ import java .util .UUID ;
1920
2021import static org .testng .Assert .assertEquals ;
2122import static org .testng .Assert .assertFalse ;
@@ -580,4 +581,27 @@ void testClearParameters() throws Exception {
580581 ps .execute ();
581582 }
582583 }
584+
585+ @ Test (groups = {"integration" })
586+ void testWriteCollection () throws Exception {
587+ String sql = "insert into `test_issue_2327` (`id`, `uuid`) values (?, ?)" ;
588+ try (Connection conn = getJdbcConnection ();
589+ PreparedStatementImpl ps = (PreparedStatementImpl ) conn .prepareStatement (sql )) {
590+
591+ try (Statement stmt = conn .createStatement ()) {
592+ stmt .execute ("CREATE TABLE IF NOT EXISTS `test_issue_2327` (`id` Nullable(String), `uuid` UUID) ENGINE Memory;" );
593+ }
594+ UUID uuid = UUID .randomUUID ();
595+ ps .setString (1 , "testId01" );
596+ ps .setObject (2 , uuid );
597+ ps .execute ();
598+
599+ try (Statement stmt = conn .createStatement ()) {
600+ ResultSet rs = stmt .executeQuery ("SELECT count(*) FROM `test_issue_2327`" );
601+ Assert .assertTrue (rs .next ());
602+ Assert .assertEquals (rs .getInt (1 ), 1 );
603+ }
604+ }
605+
606+ }
583607}
You can’t perform that action at this time.
0 commit comments