Fixing BOOL type to UNSIGNED in MySQL instances.

This commit is contained in:
Ben Guild 2016-05-21 14:17:50 +09:00
parent 57c72125b3
commit 50657fb5cf

View File

@ -30,7 +30,7 @@ func (mysql) DataTypeOf(field *StructField) string {
if sqlType == "" { if sqlType == "" {
switch dataValue.Kind() { switch dataValue.Kind() {
case reflect.Bool: case reflect.Bool:
sqlType = "boolean" sqlType = "tinyint(1) unsigned" // NOTE: "boolean" does not set as UNSIGNED by default.
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32: case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32:
if _, ok := field.TagSettings["AUTO_INCREMENT"]; ok || field.IsPrimaryKey { if _, ok := field.TagSettings["AUTO_INCREMENT"]; ok || field.IsPrimaryKey {
field.TagSettings["AUTO_INCREMENT"] = "AUTO_INCREMENT" field.TagSettings["AUTO_INCREMENT"] = "AUTO_INCREMENT"