mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-11 19:04:35 +00:00
Fix db update when id is not in record (#171)
This commit is contained in:
@@ -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
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user