[GODRIVER-1751] Struct codec does not honor custom codecs if another codec was used first Created: 16/Sep/20  Updated: 28/Oct/23  Resolved: 29/Sep/20

Status: Closed
Project: Go Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 1.4.2

Type: Bug Priority: Major - P3
Reporter: Divjot Arora (Inactive) Assignee: Divjot Arora (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related

 Description   

Reproducible example: https://play.golang.org/p/uugW5Adb3-J

In the example, the decodeInt function implements a value decoder for int32 that reads an int32 from the ValueReader and multiplies it by -1 before setting it in the struct. The expected output from the main function is

{"int": {"$numberInt":"1"}}

{Int:-1}

but the actual output is

{"int": {"$numberInt":"1"}}

{Int:1}

When using MarshalWithRegistry followed by UnmarshalWithRegistry, everything works as expected. When using Marshal followed by UnmarshalWithRegistry, the custom decoder is not honored.



 Comments   
Comment by Githook User [ 29/Sep/20 ]

Author:

{'name': 'Divjot Arora', 'email': 'divjot.arora@10gen.com', 'username': 'divjotarora'}

Message: GODRIVER-1751 Ensure codecs that cache are not shared across registries (#508)
Branch: release/1.4
https://github.com/mongodb/mongo-go-driver/commit/19f9639cbd7113f1d741638428f8aa6a562b2a47

Comment by Githook User [ 29/Sep/20 ]

Author:

{'name': 'Divjot Arora', 'email': 'divjot.arora@10gen.com', 'username': 'divjotarora'}

Message: GODRIVER-1751 Ensure codecs that cache are not shared across registries (#508)
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/202942f02b68b21f3f6253088bb1d3f7d4c08c0a

Generated at Thu Feb 08 08:37:03 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.