/
postgresql.go
48 lines (36 loc) · 1.01 KB
/
postgresql.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
// Package postgresql implements reform.Dialect for PostgreSQL.
package postgresql // import "gopkg.in/reform.v1/dialects/postgresql"
import (
"strconv"
"gopkg.in/reform.v1"
)
type postgresql struct{}
func (postgresql) String() string {
return "postgresql"
}
func (postgresql) Placeholder(index int) string {
return "$" + strconv.Itoa(index)
}
func (postgresql) Placeholders(start, count int) []string {
res := make([]string, count)
for i := 0; i < count; i++ {
res[i] = "$" + strconv.Itoa(start+i)
}
return res
}
func (postgresql) QuoteIdentifier(identifier string) string {
return `"` + identifier + `"`
}
func (postgresql) LastInsertIdMethod() reform.LastInsertIdMethod {
return reform.Returning
}
func (postgresql) SelectLimitMethod() reform.SelectLimitMethod {
return reform.Limit
}
func (postgresql) DefaultValuesMethod() reform.DefaultValuesMethod {
return reform.DefaultValues
}
// Dialect implements reform.Dialect for PostgreSQL.
var Dialect postgresql
// check interface
var _ reform.Dialect = Dialect