-
Notifications
You must be signed in to change notification settings - Fork 2
/
driver.go
60 lines (49 loc) · 1.25 KB
/
driver.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
package qbdb
import (
"strconv"
"git.ultraware.nl/NiseVoid/qb"
)
// Driver is a default driver used for tests
type Driver struct{}
// ValueString returns the placeholder for prepare values
func (d Driver) ValueString(c int) string {
return `@@`
}
// BoolString returns the notation for boolean values
func (d Driver) BoolString(v bool) string {
if v {
return `t`
}
return `f`
}
// UpsertSQL implements qb.Driver
func (d Driver) UpsertSQL(_ *qb.Table, _ []qb.Field, _ qb.Query) (string, []interface{}) {
panic(`This should not be used`)
}
// Limit implements qb.Driver
func (d Driver) Limit(sql qb.SQL, limit int) {
sql.WriteLine(`LIMIT ` + strconv.Itoa(limit))
}
// Returning implements qb.Driver
func (d Driver) Returning(b qb.SQLBuilder, q qb.Query, f []qb.Field) (string, []interface{}) {
panic(`This should not be used`)
}
var types = map[qb.DataType]string{
qb.Int: `int`,
qb.String: `string`,
qb.Bool: `boolean`,
qb.Float: `float`,
qb.Date: `date`,
qb.Time: `time`,
}
// TypeName returns the sql name for a type
func (d Driver) TypeName(t qb.DataType) string {
if s, ok := types[t]; ok {
return s
}
panic(`Unknown type`)
}
// Override returns the override map
func (d Driver) Override() qb.OverrideMap {
return qb.OverrideMap{}
}