Fix db update when id is not in record (#171)

This commit is contained in:
Janos Dobronszki
2021-06-23 13:55:09 +01:00
committed by GitHub
parent a7d19bc141
commit e421486ca9

View File

@@ -134,6 +134,9 @@ func (e *Db) Update(ctx context.Context, req *db.UpdateRequest, rsp *db.UpdateRe
// where ID is specified do a single update record update
id := req.Id
if v, ok := m[idKey].(string); ok && id == "" {
id = v
}
// if the id is blank then check the data
if len(req.Id) == 0 {
@@ -164,7 +167,7 @@ func (e *Db) Update(ctx context.Context, req *db.UpdateRequest, rsp *db.UpdateRe
bs, _ := json.Marshal(old)
return tx.Table(tableName).Save(&Record{
ID: m[idKey].(string),
ID: id,
Data: bs,
}).Error
})