mirror of https://github.com/go-gorm/gorm.git
Add unsigned support for mysql
This commit is contained in:
parent
58f379b098
commit
4fd6e62a02
14
mysql.go
14
mysql.go
|
@ -14,16 +14,26 @@ func (mysql) SqlTag(value reflect.Value, size int, autoIncrease bool) string {
|
||||||
switch value.Kind() {
|
switch value.Kind() {
|
||||||
case reflect.Bool:
|
case reflect.Bool:
|
||||||
return "boolean"
|
return "boolean"
|
||||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uintptr:
|
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32:
|
||||||
if autoIncrease {
|
if autoIncrease {
|
||||||
return "int AUTO_INCREMENT"
|
return "int AUTO_INCREMENT"
|
||||||
}
|
}
|
||||||
return "int"
|
return "int"
|
||||||
case reflect.Int64, reflect.Uint64:
|
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uintptr:
|
||||||
|
if autoIncrease {
|
||||||
|
return "int unsigned AUTO_INCREMENT"
|
||||||
|
}
|
||||||
|
return "int unsigned"
|
||||||
|
case reflect.Int64:
|
||||||
if autoIncrease {
|
if autoIncrease {
|
||||||
return "bigint AUTO_INCREMENT"
|
return "bigint AUTO_INCREMENT"
|
||||||
}
|
}
|
||||||
return "bigint"
|
return "bigint"
|
||||||
|
case reflect.Uint64:
|
||||||
|
if autoIncrease {
|
||||||
|
return "bigint unsigned AUTO_INCREMENT"
|
||||||
|
}
|
||||||
|
return "bigint unsigned"
|
||||||
case reflect.Float32, reflect.Float64:
|
case reflect.Float32, reflect.Float64:
|
||||||
return "double"
|
return "double"
|
||||||
case reflect.String:
|
case reflect.String:
|
||||||
|
|
Loading…
Reference in New Issue