fix issue in data filter for gdb.Model

This commit is contained in:
John 2019-09-16 16:54:52 +08:00
parent 33fbedffb8
commit 0d87b601cc

View File

@ -87,14 +87,16 @@ func (bs *dbBase) convertValue(fieldValue []byte, fieldType string) interface{}
// 将map的数据按照fields进行过滤只保留与表字段同名的数据
func (bs *dbBase) filterFields(table string, data map[string]interface{}) map[string]interface{} {
// Must use data copy avoiding change the origin data map.
newDataMap := make(map[string]interface{}, len(data))
if fields, err := bs.db.TableFields(table); err == nil {
for k, _ := range data {
if _, ok := fields[k]; !ok {
delete(data, k)
for k, v := range data {
if _, ok := fields[k]; ok {
newDataMap[k] = v
}
}
}
return data
return newDataMap
}
// 返回当前数据库所有的数据表名称