From b3674b5b06602f87dc1657f37abd3ab9e3a890be Mon Sep 17 00:00:00 2001 From: astaxie Date: Wed, 27 Aug 2014 11:08:32 +0800 Subject: [PATCH] support bit type --- g_appcode.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/g_appcode.go b/g_appcode.go index 532b979..d39a928 100644 --- a/g_appcode.go +++ b/g_appcode.go @@ -76,6 +76,7 @@ var typeMappingMysql = map[string]string{ "smallint unsigned": "uint16", "mediumint unsigned": "uint32", "bigint unsigned": "uint64", + "bit": "uint64", "bool": "bool", // boolean "enum": "string", // enum "set": "string", // set @@ -480,6 +481,9 @@ func (mysqlDB *MysqlDB) GetColumns(db *sql.DB, table *Table, blackList map[strin if isSQLBinaryType(dataType) { tag.Size = extractColSize(columnType) } + if isSQLBitType(dataType) { + tag.Size = extractColSize(columnType) + } } } col.Tag = tag @@ -904,6 +908,10 @@ func isSQLBinaryType(t string) bool { return t == "binary" || t == "varbinary" } +func isSQLBitType(t string) bool { + return t == "bit" +} + // extractColSize extracts field size: e.g. varchar(255) => 255 func extractColSize(colType string) string { regex := regexp.MustCompile(`^[a-z]+\(([0-9]+)\)$`)