Details
-
Bug
-
Resolution: Done
-
Major - P3
-
None
-
1.1.0
-
None
Description
Considering the following example:
type A struct {
|
X *B
|
}
|
|
|
type B struct {
|
Y string
|
}
|
|
|
func (B) MarshalBSON() ([]byte, error) {
|
return bson.Marshal(bson.M{"foo": "bar"})
|
}
|
In that case it can marshal A{X: &B} but cannot marshal A{X: nil}
If *B (instead of B) has MarshalBSON implemented it can handle nil pointer. but has no way to represent null in BSON, because MarshalBSON is defaulted to EmbeddedDocument.
I don't know what should return if we implement MarshalBSONValue in *B. "return bsontype.Null, nil, nil" doesn't seem to be correct.