Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,7 @@
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.time.temporal.ChronoField;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.*;

public class PreparedStatementImpl extends StatementImpl implements PreparedStatement, JdbcV2Wrapper {
private static final Logger LOG = LoggerFactory.getLogger(PreparedStatementImpl.class);
Expand Down Expand Up @@ -659,6 +653,8 @@ private static String encodeObject(Object x) throws SQLException {
}
tupleString.append(")");
return tupleString.toString();
} else if (x instanceof UUID) {
return "'" + escapeString(((UUID) x).toString()) + "'";
}

return escapeString(x.toString());//Escape single quotes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.util.Arrays;
import java.util.GregorianCalendar;
import java.util.TimeZone;
import java.util.UUID;

import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
Expand Down Expand Up @@ -580,4 +581,27 @@ void testClearParameters() throws Exception {
ps.execute();
}
}

@Test(groups = {"integration"})
void testWriteCollection() throws Exception {
String sql = "insert into `test_issue_2327` (`id`, `uuid`) values (?, ?)";
try (Connection conn = getJdbcConnection();
PreparedStatementImpl ps = (PreparedStatementImpl) conn.prepareStatement(sql)) {

try (Statement stmt = conn.createStatement()) {
stmt.execute("CREATE TABLE IF NOT EXISTS `test_issue_2327` (`id` Nullable(String), `uuid` UUID) ENGINE Memory;");
}
UUID uuid = UUID.randomUUID();
ps.setString(1, "testId01");
ps.setObject(2, uuid);
ps.execute();

try (Statement stmt = conn.createStatement()) {
ResultSet rs = stmt.executeQuery("SELECT count(*) FROM `test_issue_2327`");
Assert.assertTrue(rs.next());
Assert.assertEquals(rs.getInt(1), 1);
}
}

}
}
Loading