[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:
ying-jeanne
2022-12-26 09:53:52 -05:00
committed by GitHub
parent 746c7839dc
commit 12c292fd44
4 changed files with 63 additions and 11 deletions
@@ -162,6 +162,10 @@ func (r *xormRepositoryImpl) Update(ctx context.Context, item *annotations.Item)
existing.EpochEnd = item.EpochEnd
}
if item.Data != nil {
existing.Data = item.Data
}
if item.Tags != nil {
tags, err := r.tagService.EnsureTagsExist(ctx, tag.ParseTagPairs(item.Tags))
if err != nil {
@@ -183,7 +187,7 @@ func (r *xormRepositoryImpl) Update(ctx context.Context, item *annotations.Item)
return err
}
_, err = sess.Table("annotation").ID(existing.Id).Cols("epoch", "text", "epoch_end", "updated", "tags").Update(existing)
_, err = sess.Table("annotation").ID(existing.Id).Cols("epoch", "text", "epoch_end", "updated", "tags", "data").Update(existing)
return err
})
}