-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Labels
bugSomething isn't workingSomething isn't working
Description
在提交之前请先查找 已有 issues,避免重复上报。| Before submitting, please search for existing issues to avoid duplicate reports.
并且确保自己已经 | Also, ensure that you have:
- 阅读过文档 | Read the documentation
- 阅读过注释 | Reviewed the comments
- 阅读过例子 | Looked at the examples
您使用的 mongox 版本 | The version of mongox you are using
github.com/chenmingyong0423/go-mongox/v2您遇到的问题 | The issue you encountered.
- 在更新操作时,会进行一次预先序列化为
bson.M,这是出于什么考虑?
Lines 135 to 138 in 19e6f49
updates := bsonx.ToBsonM(u.updates) if len(updates) != 0 { u.updates = updates } - 它引发了如下问题
- 使用默认的编解码器,无法对自定义类型进行编解码,导致数据无法正确序列化
Lines 78 to 91 in 19e6f49
func dToM(d bson.D) bson.M { marshal, err := bson.Marshal(d) if err != nil { return nil } var m bson.M decoder := bson.NewDecoder(bson.NewDocumentReader(bytes.NewReader(marshal))) decoder.DefaultDocumentM() err = decoder.Decode(&m) if err != nil { return nil } return m } - 多一次的序列化对于追求性能的场景,会有所影响
- 使用默认的编解码器,无法对自定义类型进行编解码,导致数据无法正确序列化
- 即使不进行预先序列化,它可以正常运行
- 它引发了如下问题
- 如下,两个字段应该是有效的时间结构体,需要使用自定义的编解码器才能正确序列化,但是由于预先序列化,导致它变成不可用的数据
正确的如下:
复现步骤 | Steps to reproduce> 请提供简单的复现代码 | Please provide simple code to reproduce the issue.
错误日志或者截图 | Error logs or Screenshots
你排查的结果,或者你觉得可行的修复方案 | Your Findings or Possible Solutions
可选。我们希望你能够尽量先排查问题,帮助我们减轻维护负担。这对于你个人能力提升同样是有帮助的。| Optional. We hope you can try to troubleshoot the issue first, helping us to reduce our maintenance burden. This is also beneficial for your personal skill development
您期望的结果 | Expected Outcome
你设置的的 Go 环境 | Your Go Environment Setting
上传
go env的结果 | Upload the result ofgo env
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working