-
Notifications
You must be signed in to change notification settings - Fork 0
/
typemap.go
95 lines (76 loc) · 1.76 KB
/
typemap.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
package main
import (
"log"
"github.com/BurntSushi/toml"
)
var defaultTypeMapCfg PgTypeMapConfig
func init() {
if _, err := toml.Decode(typeMap, &defaultTypeMapCfg); err != nil {
log.Fatal(err)
}
}
const typeMap = `
[string]
db_types = ["character", "character varying", "text", "money"]
notnull_go_type = "string"
nullable_go_type = "sql.NullString"
[time]
db_types = [
"time with time zone", "time without time zone",
"timestamp without time zone", "timestamp with time zone", "date"
]
notnull_go_type = "time.Time"
nullable_go_type = "*time.Time"
[bool]
db_types = ["boolean"]
notnull_go_type = "bool"
nullable_go_type = "bool"
[smallint]
db_types = ["smallint"]
notnull_go_type = "int16"
nullable_go_type = "sql.NullInt64"
[integer]
db_types = ["integer"]
notnull_go_type = "int"
nullable_go_type = "sql.NullInt64"
[bigint]
db_types = ["bigint"]
notnull_go_type = "int64"
nullable_go_type = "sql.NullInt64"
[smallserial]
db_types = ["smallserial"]
notnull_go_type = "uint16"
nullable_go_type = "sql.NullInt64"
[serial]
db_types = ["serial"]
notnull_go_type = "uint32"
nullable_go_type = "sql.NullInt64"
[real]
db_types = ["real"]
notnull_go_type = "float32"
nullable_go_type = "sql.NullFloat64"
[numeric]
db_types = ["numeric", "double precision"]
notnull_go_type = "float64"
nullable_go_type = "sql.NullFloat64"
[bytea]
db_types = ["bytea"]
notnull_go_type = "byte"
nullable_go_type = "byte"
[json]
db_types = ["json", "jsonb"]
notnull_go_type = "[]byte"
nullable_go_type = "[]byte"
[xml]
db_types = ["xml"]
notnull_go_type = "[]byte"
nullable_go_type = "[]byte"
[interval]
db_types = ["interval"]
notnull_go_type = "time.Duration"
nullable_go_type = "*time.Duration"
[default]
db_types = ["*"]
notnull_go_type = "interface{}"
nullable_go_type = "interface{}"
`