fix unexported field or method panic

fix unexported field or method panic
This commit is contained in:
northfun 2020-10-30 10:06:24 +08:00
parent 28937fbd0c
commit d0432018ed
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