Details
-
Bug
-
Resolution: Done
-
Major - P3
-
None
-
None
-
None
Description
If I define an object containing a value of type bsoncore.Document such as
type Example struct {
|
DocField bsoncore.Document `bson:"docField"`
|
}
|
and attempt to marshal it when DocField is nil, it will fail with the following error message:
cannot transform type currentop.Query to a BSON Document: couldn't read length from src, not enough bytes
|
I can get around the issue by changing the data type to a pointer *bsoncore.Document, but this is very inelegant considering that bsoncore.Document is already nullable. It would be great if this could work as originally written. If not, could we at the very least provide an error message that's indicative of why it's not working?