Open niluan304 opened 1 week ago
The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question
template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking ✨
The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question
template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking ✨
The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question
template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking ✨
被自己的愚蠢,气笑了 So stupid —— me.
func (j JsonField) Value() (driver.Value, error) {
for i := range j.Array {
j.Array[i] += "1" // 我想要修改(加密)原来的字段,I want to modify/encrypt the fields
}
data, err := json.Marshal(j)
if err != nil {
return nil, fmt.Errorf("json marshal fail, err: %w", err)
}
return data, nil
}
should be
func (j JsonField) Value() (driver.Value, error) {
clone := slices.Clone(j.Array) // don't update receiver !!!
for i := range clone {
clone[i] += "1" // 我想要修改(加密)原来的字段,I want to modify/encrypt the fields
}
data, err := json.Marshal(JsonField{
Array: clone,
})
if err != nil {
return nil, fmt.Errorf("json marshal fail, err: %w", err)
}
return data, nil
}
GORM Playground Link
如果是必要的话,我会提供的...If necessary, I will try to do it...https://github.com/go-gorm/playground/pull/773
Description
My ENV
What I do
I got
看起来,这行代码,被执行了 3次:
Others
可能这是一个低级问题,但我对
gorm
不够熟悉。 我也尝试过debug
,却因为我的水平问题,迷失在 stack 中了。