From 99b99321e9a5c82047699db7143e34416791f93e Mon Sep 17 00:00:00 2001 From: ZhengYang Date: Thu, 21 Aug 2014 11:53:12 +0800 Subject: [PATCH] added data type mapping for postgresql --- g_appcode.go | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/g_appcode.go b/g_appcode.go index d94fbb1..30ff3ab 100644 --- a/g_appcode.go +++ b/g_appcode.go @@ -40,7 +40,7 @@ type MvcPath struct { 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{ "int": "int", // int signed "integer": "int", @@ -75,6 +75,30 @@ var typeMapping = map[string]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 type Table struct { Name string