Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Pass string instead of int array to patch subscriberList as google/jsonapi doesn’t support unmarshalling int slice
天舟6adc3c912b8b
diff --git a/backend/api/issue.go b/backend/api/issue.goindex 8bd60a8b15..ee6db2b529 100644--- a/backend/api/issue.go+++ b/backend/api/issue.go@@ -145,11 +145,14 @@ type IssuePatch struct {// Domain specific fieldsName *string `jsonapi:"attr,name"`// Status is only set manualy via IssueStatusPatch- Status *IssueStatus- Description *string `jsonapi:"attr,description"`- AssigneeId *int `jsonapi:"attr,assigneeId"`- SubscriberIdList *[]int `jsonapi:"attr,subscriberIdList"`- Payload *string `jsonapi:"attr,payload"`+ Status *IssueStatus+ Description *string `jsonapi:"attr,description"`+ AssigneeId *int `jsonapi:"attr,assigneeId"`+ // We expect a list of PrincipalId separated by `,`.+ // This is a hack because google/jsonapi doesn't support unmarshaling int slice.+ // The community has a outstanding PR to support this: https://github.com/google/jsonapi/pull/129+ SubscriberIdListStr *string `jsonapi:"attr,subscriberIdListStr"`+ Payload *string `jsonapi:"attr,payload"`}type IssueStatusPatch struct {diff --git a/backend/server/issue.go b/backend/server/issue.goindex 7c3a17f930..ca136b7fea 100644--- a/backend/server/issue.go+++ b/backend/server/issue.go@@ -157,24 +157,18 @@ func (s *Server) registerIssueRoutes(g *echo.Group) {}payloadList = append(payloadList, payload)}- if issuePatch.SubscriberIdList != nil {+ if issuePatch.SubscriberIdListStr != nil {oldSubscriberIdList := []string{}for _, item := range issue.SubscriberIdList {oldSubscriberIdList = append(oldSubscriberIdList, strconv.Itoa(item))}oldSubscriberIdStr := strings.Join(oldSubscriberIdList, ",")- newSubscriberIdList := []string{}- for _, item := range *issuePatch.SubscriberIdList {- newSubscriberIdList = append(newSubscriberIdList, strconv.Itoa(item))- }- newSubscriberIdStr := strings.Join(newSubscriberIdList, ",")-- if newSubscriberIdStr != oldSubscriberIdStr {+ if *issuePatch.SubscriberIdListStr != oldSubscriberIdStr {payload, err := json.Marshal(api.ActivityIssueFieldUpdatePayload{FieldId: api.IssueFieldSubscriberList,OldValue: oldSubscriberIdStr,- NewValue: newSubscriberIdStr,+ NewValue: *issuePatch.SubscriberIdListStr,})if err != nil {return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to marshal activity after changing issue subscribers: %v", updatedIssue.Name)).SetInternal(err)diff --git a/backend/store/issue.go b/backend/store/issue.goindex c89bf929c3..972fac2786 100644--- a/backend/store/issue.go+++ b/backend/store/issue.go@@ -283,12 +283,8 @@ func (s *IssueService) patchIssue(ctx context.Context, tx *Tx, patch *api.IssuePif v := patch.AssigneeId; v != nil {set, args = append(set, "assignee_id = ?"), append(args, *v)}- if v := patch.SubscriberIdList; v != nil {- subscriberIdList := []string{}- for _, item := range *patch.SubscriberIdList {- subscriberIdList = append(subscriberIdList, strconv.Itoa(item))- }- set, args = append(set, "subscriber_id_list = ?"), append(args, strings.Join(subscriberIdList, ","))+ if v := patch.SubscriberIdListStr; v != nil {+ set, args = append(set, "subscriber_id_list = ?"), append(args, *v)}if v := patch.Payload; v != nil {payload, err := json.Marshal(*patch.Payload)diff --git a/frontend/src/types/issue.ts b/frontend/src/types/issue.tsindex 3de76dda78..757204b290 100644--- a/frontend/src/types/issue.ts+++ b/frontend/src/types/issue.ts@@ -68,7 +68,9 @@ export type IssuePatch = {name?: string;description?: string;assigneeId?: PrincipalId;- subscriberIdList?: PrincipalId[];+ // This is a list of PrincipalId separated by `,`.+ // This is a hack because server uses google/jsonapi which doesn't support unmarshalling slice of int+ subscriberIdListStr?: string;payload?: IssuePayload;};diff --git a/frontend/src/views/IssueDetail.vue b/frontend/src/views/IssueDetail.vueindex a988baadd1..8b1fa3ccae 100644--- a/frontend/src/views/IssueDetail.vue+++ b/frontend/src/views/IssueDetail.vue@@ -508,7 +508,7 @@ export default {const updateSubscriberIdList = (newSubscriberIdList: PrincipalId[]) => {patchIssue({- subscriberIdList: newSubscriberIdList,+ subscriberIdListStr: newSubscriberIdList.join(","),});};