[GODRIVER-598] Cannot decode when any ObjectId field is null in database Created: 14/Oct/18  Updated: 28/Oct/23  Resolved: 04/Dec/18

Status: Closed
Project: Go Driver
Component/s: BSON
Affects Version/s: 0.0.16
Fix Version/s: 0.1.0

Type: Bug Priority: Major - P3
Reporter: Andre Bazaglia Assignee: Kristofer Brandow (Inactive)
Resolution: Fixed Votes: 0
Labels: beta, neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on GODRIVER-535 Add support for pointers to reflect.K... Closed
Related
related to GODRIVER-535 Add support for pointers to reflect.K... Closed

 Description   

I don't know exactly in which alpha version this issue started, but when decoding the *DocumentResult into my Go struct, it always throws an error if I have 
"myIdAttribute": null in database.

  • If struct is defined as *objectid.ObjectID, decoding fails. The error contains this relevant info: "github.com/mongodb/mongo-go-driver/bson/objectid.ObjectID.IsZero called using nil *ObjectID pointer"
  • If struct is defined using objectid.ObjectID (no pointer here), it also fails. The error message contains: "cannot decode null into an ObjectID"

So basically in case any field in my database represents an ObjectID, and its value is null in the database, my entire decode operation fails.



 Comments   
Comment by Githook User [ 04/Dec/18 ]

Author:

{'name': 'Kris Brandow', 'email': 'kris@mongodb.com', 'username': 'skriptble'}

Message: Update codec system to use reflect.Value

Add support for pointers to the BSON codec system. When doing an
interface lookup for a decoder, we now check if the type or a pointer to
the type implement the interface. If either one does, we return the
decoder for that interface.

This change changes the ValueEncoder and ValueDecoder interfaces to use
reflect.Value instead of interface{}.

Move the bson.D family of types into the primitive package.

GODRIVER-535
GODRIVER-598
GODRIVER-588
GODRIVER-645
GODRIVER-662
GODRIVER-649
GODRIVER-670

Change-Id: Idec68f74e354973160bd59f9f8fef009f026f943
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/d305fc0b97b199028c9a7def35f931224c448665

Comment by Kristofer Brandow (Inactive) [ 28/Nov/18 ]

Code Review: https://review.gerrithub.io/c/mongodb/mongo-go-driver/+/435374.

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