Skip to content

Commit 50bbce4

Browse files
committed
removed unwanted change. Fixed tests
1 parent 85a27df commit 50bbce4

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed

client-v2/src/test/java/com/clickhouse/client/datatypes/DataTypeTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1541,10 +1541,10 @@ public void testJSONScanDoesNotLeakKeysAcrossRows() throws Exception {
15411541
.serverSetting("allow_experimental_json_type", "1");
15421542

15431543
client.execute("DROP TABLE IF EXISTS " + table).get().close();
1544-
client.execute(tableDefinition(table, "data JSON"), cmdSettings).get().close();
1545-
client.execute("INSERT INTO " + table + " VALUES ('{\"a\": \"foo\"}'::JSON), ('{\"b\": \"bar\"}'::JSON)").get().close();
1544+
client.execute(tableDefinition(table, "id UInt32", "data JSON"), cmdSettings).get().close();
1545+
client.execute("INSERT INTO " + table + " VALUES (1, '{\"a\": \"foo\"}'::JSON), (2, '{\"b\": \"bar\"}'::JSON)", cmdSettings).get().close();
15461546

1547-
List<GenericRecord> records = client.queryAll("SELECT * FROM " + table + " ORDER BY data");
1547+
List<GenericRecord> records = client.queryAll("SELECT * FROM " + table + " ORDER BY id");
15481548
Assert.assertEquals(records.size(), 2);
15491549

15501550
for (GenericRecord record : records) {

jdbc-v2/src/main/java/com/clickhouse/jdbc/PreparedStatementImpl.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ private String buildSQL() throws SQLException {
135135
public ResultSet executeQuery() throws SQLException {
136136
ensureOpen();
137137
String buildSQL = buildSQL();
138-
System.out.println(buildSQL);
139138
return super.executeQueryImpl(buildSQL, localSettings);
140139
}
141140

@@ -485,6 +484,7 @@ public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws S
485484
ensureOpen();
486485
TimeZone tz = (cal == null ? defaultCalendar : cal).getTimeZone();
487486
values[parameterIndex - 1] = encodeObject(DataTypeUtils.toZonedDateTime(x, tz));
487+
values[parameterIndex - 1] = encodeObject(DataTypeUtils.toZonedDateTime(x, tz));
488488
}
489489

490490
@Override
@@ -744,10 +744,6 @@ private String encodeObject(Object x) throws SQLException {
744744

745745
private static final char QUOTE = '\'';
746746

747-
/** Matches a datetime string that ends with a decimal point followed only by zeros, e.g. "2024-09-10 22:58:20.0".
748-
* Such strings are produced by {@link Timestamp#toString()} and are rejected by ClickHouse DateTime. */
749-
private static final Pattern TRAILING_ZERO_FRACTION = Pattern.compile("(\\d{4}-\\d{2}-\\d{2}[T ]\\d{2}:\\d{2}:\\d{2})\\.0+$");
750-
751747
private static final char O_BRACKET = '[';
752748
private static final char C_BRACKET = ']';
753749

@@ -758,12 +754,7 @@ private String encodeObject(Object x, Long length) throws SQLException {
758754
if (x == null) {
759755
return "NULL";
760756
} else if (x instanceof String) {
761-
String s = (String) x;
762-
Matcher m = TRAILING_ZERO_FRACTION.matcher(s);
763-
if (m.matches()) {
764-
s = m.group(1);
765-
}
766-
return QUOTE + SQLUtils.escapeSingleQuotes(s) + QUOTE;
757+
return QUOTE + SQLUtils.escapeSingleQuotes((String) x) + QUOTE;
767758
} else if (x instanceof Boolean) {
768759
return (Boolean) x ? "1" : "0";
769760
} else if (x instanceof Date) {

0 commit comments

Comments
 (0)