File tree Expand file tree Collapse file tree 3 files changed +28
-8
lines changed
main/java/com/clickhouse/jdbc
test/java/com/clickhouse/jdbc Expand file tree Collapse file tree 3 files changed +28
-8
lines changed Original file line number Diff line number Diff line change 4444import java .time .format .DateTimeFormatter ;
4545import java .time .format .DateTimeFormatterBuilder ;
4646import java .time .temporal .ChronoField ;
47- import java .util .ArrayList ;
48- import java .util .Arrays ;
49- import java .util .Calendar ;
50- import java .util .Collection ;
51- import java .util .Collections ;
52- import java .util .List ;
53- import java .util .Map ;
47+ import java .util .*;
5448import java .util .regex .Pattern ;
5549
5650public class PreparedStatementImpl extends StatementImpl implements PreparedStatement , JdbcV2Wrapper {
@@ -681,6 +675,8 @@ private static String encodeObject(Object x) throws SQLException {
681675 }
682676 tupleString .append (")" );
683677 return tupleString .toString ();
678+ } else if (x instanceof UUID ) {
679+ return "'" + escapeString (((UUID ) x ).toString ()) + "'" ;
684680 }
685681
686682 return escapeString (x .toString ());//Escape single quotes
Original file line number Diff line number Diff line change 2121import java .util .Properties ;
2222import java .util .Random ;
2323import java .util .TimeZone ;
24+ import java .util .UUID ;
2425
2526import static org .testng .Assert .assertEquals ;
2627import static org .testng .Assert .assertFalse ;
@@ -648,4 +649,27 @@ void testBatchInsert() throws Exception {
648649 }
649650 }
650651 }
652+
653+ @ Test (groups = {"integration" })
654+ void testWriteCollection () throws Exception {
655+ String sql = "insert into `test_issue_2327` (`id`, `uuid`) values (?, ?)" ;
656+ try (Connection conn = getJdbcConnection ();
657+ PreparedStatementImpl ps = (PreparedStatementImpl ) conn .prepareStatement (sql )) {
658+
659+ try (Statement stmt = conn .createStatement ()) {
660+ stmt .execute ("CREATE TABLE IF NOT EXISTS `test_issue_2327` (`id` Nullable(String), `uuid` UUID) ENGINE Memory;" );
661+ }
662+ UUID uuid = UUID .randomUUID ();
663+ ps .setString (1 , "testId01" );
664+ ps .setObject (2 , uuid );
665+ ps .execute ();
666+
667+ try (Statement stmt = conn .createStatement ()) {
668+ ResultSet rs = stmt .executeQuery ("SELECT count(*) FROM `test_issue_2327`" );
669+ Assert .assertTrue (rs .next ());
670+ Assert .assertEquals (rs .getInt (1 ), 1 );
671+ }
672+ }
673+
674+ }
651675}
Original file line number Diff line number Diff line change 1515 <properties >
1616 <apache .httpclient.version>5.3.1</apache .httpclient.version>
1717 <slf4j .version>2.0.17</slf4j .version>
18- <ch .jdbc.revision>0.8.3 -SNAPSHOT</ch .jdbc.revision>
18+ <ch .jdbc.revision>0.8.4 -SNAPSHOT</ch .jdbc.revision>
1919 <jmh .version>1.37</jmh .version>
2020 <testcontainers .version>1.20.6</testcontainers .version>
2121
You can’t perform that action at this time.
0 commit comments