Add fieldtype for column

This commit is contained in:
Lunny Xiao 2021-07-22 11:29:16 +08:00
parent 68f18c80e2
commit b5c26997df
1 changed files with 2 additions and 0 deletions

View File

@ -167,6 +167,7 @@ func (parser *Parser) parseFieldWithNoTag(fieldIndex int, field reflect.StructFi
field.Name, sqlType, sqlType.DefaultLength, field.Name, sqlType, sqlType.DefaultLength,
sqlType.DefaultLength2, true) sqlType.DefaultLength2, true)
col.FieldIndex = []int{fieldIndex} col.FieldIndex = []int{fieldIndex}
col.FieldType = fieldValue.Type()
if field.Type.Kind() == reflect.Int64 && (strings.ToUpper(col.FieldName) == "ID" || strings.HasSuffix(strings.ToUpper(col.FieldName), ".ID")) { if field.Type.Kind() == reflect.Int64 && (strings.ToUpper(col.FieldName) == "ID" || strings.HasSuffix(strings.ToUpper(col.FieldName), ".ID")) {
col.IsAutoIncrement = true col.IsAutoIncrement = true
@ -186,6 +187,7 @@ func (parser *Parser) parseFieldWithTags(table *schemas.Table, fieldIndex int, f
MapType: schemas.TWOSIDES, MapType: schemas.TWOSIDES,
Indexes: make(map[string]int), Indexes: make(map[string]int),
DefaultIsEmpty: true, DefaultIsEmpty: true,
FieldType: fieldValue.Type(),
} }
var ctx = Context{ var ctx = Context{