mirror of
https://github.com/beego/bee.git
synced 2024-11-22 05:00:54 +00:00
support bit type
This commit is contained in:
parent
7ffe1060cc
commit
b3674b5b06
@ -76,6 +76,7 @@ var typeMappingMysql = map[string]string{
|
|||||||
"smallint unsigned": "uint16",
|
"smallint unsigned": "uint16",
|
||||||
"mediumint unsigned": "uint32",
|
"mediumint unsigned": "uint32",
|
||||||
"bigint unsigned": "uint64",
|
"bigint unsigned": "uint64",
|
||||||
|
"bit": "uint64",
|
||||||
"bool": "bool", // boolean
|
"bool": "bool", // boolean
|
||||||
"enum": "string", // enum
|
"enum": "string", // enum
|
||||||
"set": "string", // set
|
"set": "string", // set
|
||||||
@ -480,6 +481,9 @@ func (mysqlDB *MysqlDB) GetColumns(db *sql.DB, table *Table, blackList map[strin
|
|||||||
if isSQLBinaryType(dataType) {
|
if isSQLBinaryType(dataType) {
|
||||||
tag.Size = extractColSize(columnType)
|
tag.Size = extractColSize(columnType)
|
||||||
}
|
}
|
||||||
|
if isSQLBitType(dataType) {
|
||||||
|
tag.Size = extractColSize(columnType)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
col.Tag = tag
|
col.Tag = tag
|
||||||
@ -904,6 +908,10 @@ func isSQLBinaryType(t string) bool {
|
|||||||
return t == "binary" || t == "varbinary"
|
return t == "binary" || t == "varbinary"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isSQLBitType(t string) bool {
|
||||||
|
return t == "bit"
|
||||||
|
}
|
||||||
|
|
||||||
// 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 {
|
||||||
regex := regexp.MustCompile(`^[a-z]+\(([0-9]+)\)$`)
|
regex := regexp.MustCompile(`^[a-z]+\(([0-9]+)\)$`)
|
||||||
|
Loading…
Reference in New Issue
Block a user