-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathdialect.go
More file actions
28 lines (24 loc) · 704 Bytes
/
dialect.go
File metadata and controls
28 lines (24 loc) · 704 Bytes
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
package goper
// A Dialect is a set of functions for generating the SQL
// to obtain various metadata about a database.
type Dialect interface {
CreateTable(table Table) string
DropTable(table Table) string
InsertOne(table Table) string
ListTables(string) string
ListColumns(string, Table) string
Name() string
}
var dialects map[string]Dialect
func RegisterDialect(driver string, dialect Dialect) {
dialects[driver] = dialect
}
func DialectByDriver(driver string) Dialect {
return dialects[driver]
}
func init() {
dialects = make(map[string]Dialect)
RegisterDialect("mysql", new(MysqlDialect))
RegisterDialect("sqlite3", new(SqliteDialect))
RegisterDialect("postgres", new(PgDialect))
}