Update 'tags/parser.go'

Solve runtime problem:"panic: reflect.Value.Interface: cannot return value obtained from unexported field or method"
This commit is contained in:
northfun 2020-10-30 09:44:23 +08:00
parent 17f28a1314
commit 756fdfdd79
1 changed files with 3 additions and 1 deletions

View File

@ -253,7 +253,7 @@ func (parser *Parser) Parse(v reflect.Value) (*schemas.Table, error) {
addIndex(indexName, table, col, indexType)
}
}
} else {
} else if fieldValue.CanSet(){
var sqlType schemas.SQLType
if fieldValue.CanAddr() {
if _, ok := fieldValue.Addr().Interface().(convert.Conversion); ok {
@ -272,6 +272,8 @@ func (parser *Parser) Parse(v reflect.Value) (*schemas.Table, error) {
if fieldType.Kind() == reflect.Int64 && (strings.ToUpper(col.FieldName) == "ID" || strings.HasSuffix(strings.ToUpper(col.FieldName), ".ID")) {
idFieldColName = col.Name
}
} else {
continue
}
if col.IsAutoIncrement {
col.Nullable = false