1
0
mirror of https://github.com/beego/bee.git synced 2024-11-25 20:10:55 +00:00

added interval & uuid as string type for postgres

This commit is contained in:
ZhengYang 2014-09-04 10:53:29 +08:00
parent 9f45b59a99
commit 9fd3e28cb6

View File

@ -118,15 +118,17 @@ var typeMappingPostgres = map[string]string{
"time": "time.Time", "time": "time.Time",
"timestamp": "time.Time", "timestamp": "time.Time",
"timestamp without time zone": "time.Time", "timestamp without time zone": "time.Time",
"real": "float32", // float & decimal "interval": "string", // time interval, string for now
"double precision": "float64", "real": "float32", // float & decimal
"decimal": "float64", "double precision": "float64",
"numeric": "float64", "decimal": "float64",
"money": "float64", // money "numeric": "float64",
"bytea": "string", // binary "money": "float64", // money
"tsvector": "string", // fulltext "bytea": "string", // binary
"ARRAY": "string", // array "tsvector": "string", // fulltext
"USER-DEFINED": "string", // user defined "ARRAY": "string", // array
"USER-DEFINED": "string", // user defined
"uuid": "string", // uuid
} }
// Table represent a table in a database // Table represent a table in a database
@ -668,6 +670,9 @@ func (postgresDB *PostgresDB) GetColumns(db *sql.DB, table *Table, blackList map
if isSQLBinaryType(dataType) { if isSQLBinaryType(dataType) {
tag.Size = extractColSize(columnType) tag.Size = extractColSize(columnType)
} }
if isSQLStrangeType(dataType) {
tag.Type = dataType
}
} }
} }
col.Tag = tag col.Tag = tag
@ -914,6 +919,9 @@ func isSQLBinaryType(t string) bool {
func isSQLBitType(t string) bool { func isSQLBitType(t string) bool {
return t == "bit" return t == "bit"
} }
func isSQLStrangeType(t string) bool {
return t == "interval" || t == "uuid"
}
// extractColSize extracts field size: e.g. varchar(255) => 255 // extractColSize extracts field size: e.g. varchar(255) => 255
func extractColSize(colType string) string { func extractColSize(colType string) string {