[Bug] Fix annotations update/patch (#60385)
* fix annotations update/patch * verify that when update doesn't contain data, we will not update data
This commit is contained in:
@@ -278,6 +278,11 @@ func (hs *HTTPServer) UpdateAnnotation(c *models.ReqContext) response.Response {
|
||||
EpochEnd: cmd.TimeEnd,
|
||||
Text: cmd.Text,
|
||||
Tags: cmd.Tags,
|
||||
Data: annotation.Data,
|
||||
}
|
||||
|
||||
if cmd.Data != nil {
|
||||
item.Data = cmd.Data
|
||||
}
|
||||
|
||||
if err := hs.annotationsRepo.Update(c.Req.Context(), &item); err != nil {
|
||||
@@ -328,6 +333,7 @@ func (hs *HTTPServer) PatchAnnotation(c *models.ReqContext) response.Response {
|
||||
EpochEnd: annotation.TimeEnd,
|
||||
Text: annotation.Text,
|
||||
Tags: annotation.Tags,
|
||||
Data: annotation.Data,
|
||||
}
|
||||
|
||||
if cmd.Tags != nil {
|
||||
@@ -346,6 +352,10 @@ func (hs *HTTPServer) PatchAnnotation(c *models.ReqContext) response.Response {
|
||||
existing.EpochEnd = cmd.TimeEnd
|
||||
}
|
||||
|
||||
if cmd.Data != nil {
|
||||
existing.Data = cmd.Data
|
||||
}
|
||||
|
||||
if err := hs.annotationsRepo.Update(c.Req.Context(), &existing); err != nil {
|
||||
return response.ErrOrFallback(500, "Failed to update annotation", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user