prevent panic when struct with unexport field #1839

Merged
lunny merged 4 commits from :fix_panic_with_unexport_fields into master 2020-12-02 14:07:45 +00:00
Showing only changes of commit a6b65d30c7 - Show all commits

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