mirror of
https://github.com/beego/bee.git
synced 2024-11-22 05:00:54 +00:00
added data type mapping for postgresql
This commit is contained in:
parent
5c85c10b18
commit
99b99321e9
26
g_appcode.go
26
g_appcode.go
@ -40,7 +40,7 @@ type MvcPath struct {
|
|||||||
RouterPath string
|
RouterPath string
|
||||||
}
|
}
|
||||||
|
|
||||||
// typeMapping maps a SQL data type to its corresponding Go data type
|
// typeMapping maps SQL data type to corresponding Go data type
|
||||||
var typeMapping = map[string]string{
|
var typeMapping = map[string]string{
|
||||||
"int": "int", // int signed
|
"int": "int", // int signed
|
||||||
"integer": "int",
|
"integer": "int",
|
||||||
@ -75,6 +75,30 @@ var typeMapping = map[string]string{
|
|||||||
"varbinary": "string",
|
"varbinary": "string",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// typeMappingPostgres maps SQL data type to corresponding Go data type
|
||||||
|
var typeMappingPostgres = map[string]string{
|
||||||
|
"serial": "int", // serial
|
||||||
|
"big serial": "int64",
|
||||||
|
"smallint": "int16", // int
|
||||||
|
"integer": "int",
|
||||||
|
"bigint": "int64",
|
||||||
|
"boolean": "bool", // bool
|
||||||
|
"char": "string", // string
|
||||||
|
"character": "string",
|
||||||
|
"character varying": "string",
|
||||||
|
"varchar": "string",
|
||||||
|
"text": "string",
|
||||||
|
"date": "time.Time", // time
|
||||||
|
"time": "time.Time",
|
||||||
|
"timestamp": "time.Time",
|
||||||
|
"real": "float32", // float & decimal
|
||||||
|
"double precision": "float64",
|
||||||
|
"decimal": "float64",
|
||||||
|
"numeric": "float64",
|
||||||
|
"money": "float64", // money
|
||||||
|
"bytea": "string", // binary
|
||||||
|
}
|
||||||
|
|
||||||
// Table represent a table in a database
|
// Table represent a table in a database
|
||||||
type Table struct {
|
type Table struct {
|
||||||
Name string
|
Name string
|
||||||
|
Loading…
Reference in New Issue
Block a user