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

Driver should not allow insertion of docs with dots in keys

    XMLWordPrintable

    Details

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

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved: