This is an automated email from the ASF dual-hosted git repository.
klesh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to refs/heads/main by this push:
new 6b358dfbf fix(tapd): workspace's id and parent_id fields are
compatible with uint64 and string types (#6239)
6b358dfbf is described below
commit 6b358dfbf19fdf435082bb98e882ddfd9f7a7750
Author: Lynwee <[email protected]>
AuthorDate: Fri Oct 13 13:13:23 2023 +0800
fix(tapd): workspace's id and parent_id fields are compatible with uint64
and string types (#6239)
---
backend/helpers/pluginhelper/api/mapstructure.go | 7 ++++---
backend/plugins/tapd/models/workspace.go | 4 ++--
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/backend/helpers/pluginhelper/api/mapstructure.go
b/backend/helpers/pluginhelper/api/mapstructure.go
index d4bc9fd59..ef9d09456 100644
--- a/backend/helpers/pluginhelper/api/mapstructure.go
+++ b/backend/helpers/pluginhelper/api/mapstructure.go
@@ -67,9 +67,10 @@ func DecodeHook(f reflect.Type, t reflect.Type, data
interface{}) (interface{},
func DecodeMapStruct(input map[string]interface{}, result interface{},
zeroFields bool) errors.Error {
result = models.UnwrapObject(result)
decoder, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{
- ZeroFields: zeroFields,
- DecodeHook: mapstructure.ComposeDecodeHookFunc(DecodeHook),
- Result: result,
+ ZeroFields: zeroFields,
+ DecodeHook:
mapstructure.ComposeDecodeHookFunc(DecodeHook),
+ Result: result,
+ WeaklyTypedInput: true,
})
if err != nil {
return errors.Convert(err)
diff --git a/backend/plugins/tapd/models/workspace.go
b/backend/plugins/tapd/models/workspace.go
index 62b4df32a..a4ebff625 100644
--- a/backend/plugins/tapd/models/workspace.go
+++ b/backend/plugins/tapd/models/workspace.go
@@ -42,7 +42,7 @@ type WorkspaceResponse struct {
type TapdWorkspace struct {
common.Scope `mapstructure:",squash"`
- Id uint64 `gorm:"primaryKey;type:BIGINT"
mapstructure:"id" json:"id"`
+ Id uint64 `gorm:"primaryKey;type:BIGINT"
mapstructure:"id" json:"id,string"`
Name string `gorm:"type:varchar(255)"
mapstructure:"name" json:"name"`
PrettyName string `gorm:"type:varchar(255)"
mapstructure:"pretty_name" json:"pretty_name"`
Category string `gorm:"type:varchar(255)"
mapstructure:"category" json:"category"`
@@ -51,7 +51,7 @@ type TapdWorkspace struct {
BeginDate *common.CSTTime `mapstructure:"begin_date"
json:"begin_date"`
EndDate *common.CSTTime `mapstructure:"end_date" json:"end_date"`
ExternalOn string `gorm:"type:varchar(255)"
mapstructure:"external_on" json:"external_on"`
- ParentId uint64 `gorm:"type:BIGINT"
mapstructure:"parent_id,string" json:"parent_id"`
+ ParentId uint64 `gorm:"type:BIGINT"
mapstructure:"parent_id,string" json:"parent_id,string"`
Creator string `gorm:"type:varchar(255)"
mapstructure:"creator" json:"creator"`
Created *common.CSTTime `mapstructure:"created" json:"created"`
}