File tree 3 files changed +28
-8
lines changed
main/java/com/clickhouse/jdbc
test/java/com/clickhouse/jdbc
3 files changed +28
-8
lines changed Original file line number Diff line number Diff line change 44
44
import java .time .format .DateTimeFormatter ;
45
45
import java .time .format .DateTimeFormatterBuilder ;
46
46
import 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 .*;
54
48
import java .util .regex .Pattern ;
55
49
56
50
public class PreparedStatementImpl extends StatementImpl implements PreparedStatement , JdbcV2Wrapper {
@@ -681,6 +675,8 @@ private static String encodeObject(Object x) throws SQLException {
681
675
}
682
676
tupleString .append (")" );
683
677
return tupleString .toString ();
678
+ } else if (x instanceof UUID ) {
679
+ return "'" + escapeString (((UUID ) x ).toString ()) + "'" ;
684
680
}
685
681
686
682
return escapeString (x .toString ());//Escape single quotes
Original file line number Diff line number Diff line change 21
21
import java .util .Properties ;
22
22
import java .util .Random ;
23
23
import java .util .TimeZone ;
24
+ import java .util .UUID ;
24
25
25
26
import static org .testng .Assert .assertEquals ;
26
27
import static org .testng .Assert .assertFalse ;
@@ -648,4 +649,27 @@ void testBatchInsert() throws Exception {
648
649
}
649
650
}
650
651
}
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
+ }
651
675
}
Original file line number Diff line number Diff line change 15
15
<properties >
16
16
<apache .httpclient.version>5.3.1</apache .httpclient.version>
17
17
<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>
19
19
<jmh .version>1.37</jmh .version>
20
20
<testcontainers .version>1.20.6</testcontainers .version>
21
21
You can’t perform that action at this time.
0 commit comments