package foundation.persist.adapter;
|
|
import foundation.server.config.DBaseType;
|
|
public class DefaultAdapter implements IDBAdapter {
|
|
@Override
|
public String toSqlString(DBaseType dbaseType) {
|
return null;
|
}
|
|
@Override
|
public String getFunciton(DBaseType dbaseType, String functionName) {
|
if ("tempFrom".equalsIgnoreCase(functionName)) {
|
return getTempFrom(dbaseType);
|
}
|
if ("defaultTilde".equalsIgnoreCase(functionName)) {
|
return getDefaultTilde(dbaseType);
|
}
|
if ("defaultNA".equalsIgnoreCase(functionName)) {
|
return getDefaultNA(dbaseType);
|
}
|
if ("commentTable".equalsIgnoreCase(functionName)) {
|
return getCommentTable(dbaseType);
|
}
|
|
return null;
|
}
|
|
private String getCommentTable(DBaseType dbaseType) {
|
if (dbaseType.isOracle()) {
|
return "select * from user_tab_comments ";
|
}
|
else if (dbaseType.isMySQL()) {
|
return "select table_name, column_name, column_comment comments from information_schema.columns ";
|
}
|
else if (dbaseType.isSQLServer()) {
|
return "select c.column_name, c.table_name, p.value as comments from information_schema.columns c " +
|
"left join sys.extended_properties p on c.table_name = object_name(p.major_id) and c.column_name = p.minor_id";
|
}
|
return "select * from user_tab_comments";
|
}
|
|
private String getTempFrom(DBaseType dbaseType) {
|
if (dbaseType.isOracle()) {
|
return " from dual";
|
}
|
else if (dbaseType.isMySQL()) {
|
return "";
|
}
|
else if (dbaseType.isSQLServer()) {
|
return "";
|
}
|
return "listagg";
|
}
|
|
private String getDefaultTilde(DBaseType dbaseType) {
|
if (dbaseType.isOracle()) {
|
return "to_char('~')";
|
}
|
else if (dbaseType.isMySQL()) {
|
return "'~'";
|
}
|
else if (dbaseType.isSQLServer()) {
|
return "'~'";
|
}
|
return "to_char('~')";
|
}
|
|
private String getDefaultNA(DBaseType dbaseType) {
|
if (dbaseType.isOracle()) {
|
return "to_char('--')";
|
}
|
else if (dbaseType.isMySQL()) {
|
return "'--'";
|
}
|
else if (dbaseType.isSQLServer()) {
|
return "'--'";
|
}
|
return "to_char('--')";
|
}
|
|
}
|