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 43
43
import java .time .format .DateTimeFormatter ;
44
44
import java .time .format .DateTimeFormatterBuilder ;
45
45
import 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 .*;
53
47
54
48
public class PreparedStatementImpl extends StatementImpl implements PreparedStatement , JdbcV2Wrapper {
55
49
private static final Logger LOG = LoggerFactory .getLogger (PreparedStatementImpl .class );
@@ -659,6 +653,8 @@ private static String encodeObject(Object x) throws SQLException {
659
653
}
660
654
tupleString .append (")" );
661
655
return tupleString .toString ();
656
+ } else if (x instanceof UUID ) {
657
+ return "'" + escapeString (((UUID ) x ).toString ()) + "'" ;
662
658
}
663
659
664
660
return escapeString (x .toString ());//Escape single quotes
Original file line number Diff line number Diff line change 16
16
import java .util .Arrays ;
17
17
import java .util .GregorianCalendar ;
18
18
import java .util .TimeZone ;
19
+ import java .util .UUID ;
19
20
20
21
import static org .testng .Assert .assertEquals ;
21
22
import static org .testng .Assert .assertFalse ;
@@ -580,4 +581,27 @@ void testClearParameters() throws Exception {
580
581
ps .execute ();
581
582
}
582
583
}
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
+ }
583
607
}
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