Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-998

Driver should not allow insertion of docs with dots in keys

    • Type: Icon: Bug Bug
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 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" }
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            david.golden@mongodb.com David Golden
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: