mirror of
https://github.com/CodePhiliaX/Chat2DB.git
synced 2025-08-06 01:36:46 +08:00
fix escapeString
This commit is contained in:
@ -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));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user