mirror of
https://gitee.com/johng/gf
synced 2026-07-07 06:15:15 +08:00
database/gdb: fix confusing error message in Insert/Update operations when table not exist or the table contains no fields (#3553)
This commit is contained in:
@ -381,6 +381,9 @@ func (c *Core) mappingAndFilterData(ctx context.Context, schema, table string, d
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(fieldsMap) == 0 {
|
||||
return nil, gerror.Newf(`The table %s may not exist, or the table contains no fields`, table)
|
||||
}
|
||||
fieldsKeyMap := make(map[string]interface{}, len(fieldsMap))
|
||||
for k := range fieldsMap {
|
||||
fieldsKeyMap[k] = nil
|
||||
@ -406,6 +409,9 @@ func (c *Core) mappingAndFilterData(ctx context.Context, schema, table string, d
|
||||
delete(data, dataKey)
|
||||
}
|
||||
}
|
||||
if len(data) == 0 {
|
||||
return nil, gerror.Newf(`input data match no fields in table %s`, table)
|
||||
}
|
||||
}
|
||||
return data, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user