[GODRIVER-1680] Add typeDecoder interface and dedicated bson.D decoder Created: 10/Jul/20  Updated: 28/Oct/23  Resolved: 13/Jul/20

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

Type: Improvement 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:
Gantt Dependency
has to be done before GODRIVER-1681 Add typeDecoder implementations for a... Closed
has to be done before GODRIVER-1682 Call typeDecoder from recursive decoders Closed
Epic Link: GODRIVER-1587

 Description   

Introduce an unexported typeDecoder interface to bsoncodec:

type typeDecoder interface {
    decodeType(DecodeContext, bsonrw.ValueReader) (reflect.Value, error)
}

Also add a decodeAdapter type that contains both a typeDecoder and ValueDecoder which can be added to a Registry.

Modify EmptyInterfaceCodec to implement both typeDecoder and ValueDecoder. When delegating to another codec, it should delegate to typeDecoder if possible and fallback to ValueDecoder if not.

Add a dedicated bson.D decoder which delegates to the typeDecoder for interface{} if it exists (which it should in the default case) and falls back to ValueDecoder if not (e.g. if the decoder for interface{} has been overriden).



 Comments   
Comment by Githook User [ 13/Jul/20 ]

Author:

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

Message: GODRIVER-1680 Add typeDecoder and dedicated bson.D decoder (#447)

Co-authored-by: David Bartley <bartle@stripe.com>
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/a6cd2226c7836c1264a00b7101f751e95eeef570

Comment by Divjot Arora (Inactive) [ 10/Jul/20 ]

https://github.com/mongodb/mongo-go-driver/pull/447

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