-
Type: Bug
-
Resolution: Won't Fix
-
Priority: Major - P3
-
None
-
Affects Version/s: 1.0.1
-
Component/s: None
-
None
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" }
- 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