Details
-
Bug
-
Status: Closed
-
Major - P3
-
Resolution: Won't Fix
-
1.0.1
-
None
-
None
-
None
Description
The driver allows inserting keys with "." characters, which driver still are not supposed to support.
func main() {
|
client, err := mongo.NewClient(options.Client().ApplyURI("mongodb://localhost:27017"))
|
if err != nil {
|
panic(err)
|
}
|
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
|
defer cancel()
|
err = client.Connect(ctx)
|
if err != nil {
|
panic(err)
|
}
|
|
collection := client.Database("test").Collection("dottest")
|
|
res, err := collection.InsertOne(context.Background(), bson.M{"hello.world": "world"})
|
if err != nil {
|
panic(err)
|
}
|
id := res.InsertedID
|
fmt.Println("Inserted", id)
|
|
res, err = collection.InsertOne(context.Background(), bson.D{{"hello.world", "world"}})
|
if err != nil {
|
panic(err)
|
}
|
id = res.InsertedID
|
fmt.Println("Inserted", id)
|
}
|
Result:
MongoDB Enterprise > db.dottest.find()
|
{ "_id" : ObjectId("5cc1a94223fd3159fd7faf96"), "hello.world" : "world" }
|
{ "_id" : ObjectId("5cc1a94223fd3159fd7faf97"), "hello.world" : "world" }
|
Attachments
Issue Links
- is depended on by
-
TOOLS-1335 mongoimport imports fields with dots (.) from JSON
-
- Closed
-
- related to
-
SERVER-30575 Please add escaping convention for dot and dollar signs!
-
- Backlog
-
-
DRIVERS-308 BSON Key Validation in Drivers
-
- Closed
-