[GODRIVER-1337] Support inline fields as pointer to struct/map (not just struct/map) Created: 10/Oct/19  Updated: 10/Oct/19  Resolved: 10/Oct/19

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

Type: Bug Priority: Major - P3
Reporter: Evghenii Maslennikov Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

go 1.13, linux



 Description   

Can't marshal/unmarshal inline structs that are under the pointer

Example:
```golang

package foobar

import (
"context"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
"log"
"testing"
"time"
)

type MContainer struct

{ M int `bson:"m,omitempty"` }

type FoobarWithPointer struct

{ *MContainer `bson:",inline"` A int }

type FoobarPointerless struct

{ MContainer `bson:",inline"` A int }

func TestSandbox(t *testing.T) {
ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)
client, _ := mongo.Connect(ctx, options.Client().ApplyURI("mongodb://localhost:27017"))

collection := client.Database("testing").Collection("numbers")
_, err := collection.InsertOne(ctx, &FoobarPointerless{A: 1, MContainer: MContainer{M: 10}})
log.Printf("pointerless: err = %s", err) // nil

_, err = collection.InsertOne(ctx, &FoobarWithPointer{A: 1, MContainer: &MContainer{M: 10}})
log.Printf("with pointer: err = %s", err) // cannot transform type *foobar.FoobarWithPointer to a BSON Document: (struct foobar.FoobarWithPointer) inline fields must be either a struct or a map
}

```



 Comments   
Comment by Esha Bhargava [ 10/Oct/19 ]

Same as GODRIVER-1305

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