Closed
Description
Issue Description
It's impossible to bind the body of a request on a struct with primitive.ObjectID from the official mongodb mongo-driver
Expected behaviour
The string value of the id correctly mapped to primitive.ObjectID and no errors, as it was on older releases (this problem happens to me after an upgrade to v4.1.17)
Actual behaviour
It gives this error:
code=400, message=unknown type, internal=unknown type
Steps to reproduce
Just bind to a struct with a primitive.ObjectID
Working code to debug
import (
"github.com/labstack/echo"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
)
type User struct {
ID primitive.ObjectID `bson:"_id,omitempty" json:"_id,omitempty"`
...
}
func handleUpdate(c echo.Context) error {
item := new(User)
err := c.Bind(item)
if err != nil {
log.Println(err.Error())
}
...
}
Version/commit
v4.1.17
Metadata
Metadata
Assignees
Labels
No labels