forked from slicebit/qb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dialect_mysql.go
57 lines (45 loc) · 1.46 KB
/
dialect_mysql.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
package qb
import "fmt"
// MysqlDialect is a type of dialect that can be used with mysql driver
type MysqlDialect struct {
escaping bool
}
// Escape wraps the string with escape characters of the dialect
func (d *MysqlDialect) Escape(str string) string {
if d.escaping {
return fmt.Sprintf("`%s`", str)
}
return str
}
// EscapeAll wraps all elements of string array
func (d *MysqlDialect) EscapeAll(strings []string) []string {
return escapeAll(d, strings[0:])
}
// SetEscaping sets the escaping parameter of dialect
func (d *MysqlDialect) SetEscaping(escaping bool) {
d.escaping = escaping
}
// Escaping gets the escaping parameter of dialect
func (d *MysqlDialect) Escaping() bool {
return d.escaping
}
// Placeholder returns the placeholder for bindings in the sql
func (d *MysqlDialect) Placeholder() string {
return "?"
}
// Placeholders returns the placeholders for bindings in the sql
func (d *MysqlDialect) Placeholders(values ...interface{}) []string {
return placeholders(d, values...)
}
// AutoIncrement generates auto increment sql of current dialect
func (d *MysqlDialect) AutoIncrement() string {
return "AUTO_INCREMENT"
}
// Reset does nothing for the default driver
func (d *MysqlDialect) Reset() {}
// SupportsUnsigned returns whether driver supports unsigned type mappings or not
func (d *MysqlDialect) SupportsUnsigned() bool { return true }
// Driver returns the current driver of dialect
func (d *MysqlDialect) Driver() string {
return "mysql"
}