fix escapeString

This commit is contained in:
zgq
2024-05-24 22:00:45 +08:00
parent 37db887383
commit 053ed0d30a
2 changed files with 7 additions and 6 deletions

View File

@ -1,6 +1,7 @@
package ai.chat2db.plugin.mysql.type;
import ai.chat2db.spi.SQLValueProcessor;
import ai.chat2db.spi.jdbc.DefaultSQLValueProcessor;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.io.WKBReader;
@ -62,9 +63,9 @@ public enum MysqlValueProcessorEnum implements SQLValueProcessor {
dbGeometry = wkbReader.read(wkb);
dbGeometry.setSRID(srid);
}
return dbGeometry.toString();
return DefaultSQLValueProcessor.escapeString(dbGeometry.toString());
} catch (Exception e) {
return rs.getString(index);
return DefaultSQLValueProcessor.escapeString(rs.getString(index));
}
}
};

View File

@ -50,7 +50,7 @@ public class DefaultSQLValueProcessor implements SQLValueProcessor {
return "'" + escapeString(object) + "'";
}
private String escapeString(Object object) {
public static String escapeString(Object object) {
String s = (String) object;
if (StringUtils.isBlank(s)) {
return "";
@ -58,7 +58,7 @@ public class DefaultSQLValueProcessor implements SQLValueProcessor {
return s.replace("\\", "\\\\").replace("'", "''");
}
private String converterClob2Str(Clob c) {
public static String converterClob2Str(Clob c) {
StringBuilder stringBuilder = new StringBuilder();
try (Reader reader = c.getCharacterStream()) {
BufferedReader bufferedReader = new BufferedReader(reader);
@ -72,7 +72,7 @@ public class DefaultSQLValueProcessor implements SQLValueProcessor {
}
}
private String converterByteArray2Str(byte[] bytes) {
public static String converterByteArray2Str(byte[] bytes) {
return "0x" + BaseEncoding.base16().encode(bytes);
}
}