P15GEN2\59518
2025-10-10 9f6890646993d16260d4201d613c092132856127
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
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('--')";
    }
 
}