mirror of
https://github.com/CodePhiliaX/Chat2DB.git
synced 2025-07-30 03:03:13 +08:00
fix(chat2db-mysql): optimize valueProcessor
This commit is contained in:
@ -7,6 +7,8 @@ import ai.chat2db.spi.jdbc.DefaultValueProcessor;
|
||||
import ai.chat2db.spi.model.JDBCDataValue;
|
||||
import ai.chat2db.spi.model.SQLDataValue;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@ -17,6 +19,8 @@ import java.util.Objects;
|
||||
public class OracleValueProcessor extends DefaultValueProcessor {
|
||||
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(OracleValueProcessor.class);
|
||||
|
||||
@Override
|
||||
public String getJdbcValue(JDBCDataValue dataValue) {
|
||||
if (OracleColumnTypeEnum.LONG_RAW.getColumnType().getTypeName().equalsIgnoreCase(dataValue.getType())) {
|
||||
@ -54,19 +58,47 @@ public class OracleValueProcessor extends DefaultValueProcessor {
|
||||
|
||||
@Override
|
||||
public String convertSQLValueByType(SQLDataValue dataValue) {
|
||||
return OracleValueProcessorFactory.getValueProcessor(dataValue.getDateTypeName()).convertSQLValueByType(dataValue);
|
||||
try {
|
||||
DefaultValueProcessor valueProcessor = OracleValueProcessorFactory.getValueProcessor(dataValue.getDateTypeName());
|
||||
if (Objects.nonNull(valueProcessor)) {
|
||||
return valueProcessor.convertSQLValueByType(dataValue);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("convertSQLValueByType error", e);
|
||||
return super.convertSQLValueByType(dataValue);
|
||||
}
|
||||
return super.convertSQLValueByType(dataValue);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String convertJDBCValueByType(JDBCDataValue dataValue) {
|
||||
String type = dataValue.getType();
|
||||
return OracleValueProcessorFactory.getValueProcessor(type).convertJDBCValueByType(dataValue);
|
||||
try {
|
||||
DefaultValueProcessor valueProcessor = OracleValueProcessorFactory.getValueProcessor(type);
|
||||
if (Objects.nonNull(valueProcessor)) {
|
||||
return valueProcessor.convertJDBCValueByType(dataValue);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("convertJDBCValueByType error", e);
|
||||
return super.convertJDBCValueByType(dataValue);
|
||||
}
|
||||
return super.convertJDBCValueByType(dataValue);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String convertJDBCValueStrByType(JDBCDataValue dataValue) {
|
||||
return OracleValueProcessorFactory.getValueProcessor(dataValue.getType()).convertJDBCValueStrByType(dataValue);
|
||||
String type = dataValue.getType();
|
||||
try {
|
||||
DefaultValueProcessor valueProcessor = OracleValueProcessorFactory.getValueProcessor(type);
|
||||
if (Objects.nonNull(valueProcessor)) {
|
||||
return valueProcessor.convertJDBCValueStrByType(dataValue);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("convertJDBCValueStrByType error", e);
|
||||
return super.convertJDBCValueStrByType(dataValue);
|
||||
}
|
||||
return super.convertJDBCValueStrByType(dataValue);
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class OracleValueProcessorFactory {
|
||||
}
|
||||
|
||||
public static DefaultValueProcessor getValueProcessor(String type) {
|
||||
return PROCESSOR_MAP.getOrDefault(type, new DefaultValueProcessor());
|
||||
return PROCESSOR_MAP.get(type);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -52,9 +52,4 @@ public class OracleLongRawProcessor extends DefaultValueProcessor {
|
||||
return EasyStringUtils.quoteString(blobHexString);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String value = "0x123456";
|
||||
value = value.substring(2);
|
||||
System.out.println("value = " + value);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user