-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathdialect.go
executable file
·126 lines (98 loc) · 2.98 KB
/
dialect.go
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
package dsc
import (
"errors"
)
var errUnsupportedOperation = errors.New("unsupported operation")
type DefaultDialect struct{}
func (d DefaultDialect) GetDatastores(manager Manager) ([]string, error) {
return nil, nil
}
func (d DefaultDialect) GetTables(manager Manager, datastore string) ([]string, error) {
return nil, nil
}
func (d DefaultDialect) DropTable(manager Manager, datastore string, table string) error {
return nil
}
func (d DefaultDialect) IsKeyCheckSwitchSessionLevel() bool {
return true
}
func (d DefaultDialect) CreateTable(manager Manager, datastore string, table string, options interface{}) error {
return nil
}
func (d DefaultDialect) CanCreateDatastore(manager Manager) bool {
return false
}
func (d DefaultDialect) GetColumns(manager Manager, datastore, table string) ([]Column, error) {
return []Column{}, nil
}
func (d DefaultDialect) CreateDatastore(manager Manager, datastore string) error {
return errUnsupportedOperation
}
func (d DefaultDialect) CanDropDatastore(manager Manager) bool {
return false
}
func (d DefaultDialect) DropDatastore(manager Manager, datastore string) error {
return errUnsupportedOperation
}
func (d DefaultDialect) GetCurrentDatastore(manager Manager) (string, error) {
return "", nil
}
func (d DefaultDialect) BulkInsertType() string {
return ""
}
func (d DefaultDialect) GetSequence(manager Manager, name string) (int64, error) {
return 0, errUnsupportedOperation
}
func (d DefaultDialect) GetKeyName(manager Manager, datastore, table string) string {
return ""
}
func (d DefaultDialect) IsAutoincrement(manager Manager, datastore, table string) bool {
return false
}
func (d DefaultDialect) CanPersistBatch() bool {
return false
}
func (d DefaultDialect) Init(manager Manager, connection Connection) error {
return nil
}
//DisableForeignKeyCheck disables fk check
func (d DefaultDialect) DisableForeignKeyCheck(manager Manager, connection Connection) error {
return nil
}
//DisableForeignKeyCheck disables fk check
func (d DefaultDialect) EnableForeignKeyCheck(manager Manager, connection Connection) error {
return nil
}
func (d DefaultDialect) NormalizeSQL(SQL string) string {
return SQL
}
func (d DefaultDialect) ShowCreateTable(manager Manager, table string) (string, error) {
return "", errors.New("unsupported")
}
func (d DefaultDialect) CanHandleTransaction() bool {
return false
}
//EachTable iterates each datastore table
func (d DefaultDialect) EachTable(manager Manager, handler func(table string) error) error {
dbname, err := d.GetCurrentDatastore(manager)
if err != nil {
return err
}
tables, err := d.GetTables(manager, dbname)
if err != nil {
return err
}
for _, table := range tables {
if err := handler(table); err != nil {
return err
}
}
return err
}
func (d DefaultDialect) Ping(manager Manager) error {
return nil
}
//NewDefaultDialect crates a defulat dialect. DefaultDialect can be used as a embeddable struct (super class).
func NewDefaultDialect() DatastoreDialect {
return &DefaultDialect{}
}