{
  "description": "insertOne-dots_and_dollars",
  "schemaVersion": "1.0",
  "createEntities": [
    {
      "client": {
        "id": "client0",
        "observeEvents": [
          "commandStartedEvent"
        ]
      }
    },
    {
      "database": {
        "id": "database0",
        "client": "client0",
        "databaseName": "crud-tests"
      }
    },
    {
      "collection": {
        "id": "collection0",
        "database": "database0",
        "collectionName": "coll0"
      }
    },
    {
      "collection": {
        "id": "collection1",
        "database": "database0",
        "collectionName": "coll1",
        "collectionOptions": {
          "writeConcern": {
            "w": 0
          }
        }
      }
    }
  ],
  "initialData": [
    {
      "collectionName": "coll0",
      "databaseName": "crud-tests",
      "documents": []
    }
  ],
  "tests": [
    {
      "description": "Inserting document with top-level dollar-prefixed key on 5.0+ server",
      "runOnRequirements": [
        {
          "minServerVersion": "5.0"
        }
      ],
      "operations": [
        {
          "name": "insertOne",
          "object": "collection0",
          "arguments": {
            "document": {
              "_id": 1,
              "$a": 1
            }
          },
          "expectResult": {
            "$$unsetOrMatches": {
              "insertedId": {
                "$$unsetOrMatches": 1
              }
            }
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client0",
          "events": [
            {
              "commandStartedEvent": {
                "command": {
                  "insert": "coll0",
                  "documents": [
                    {
                      "_id": 1,
                      "$a": 1
                    }
                  ]
                }
              }
            }
          ]
        }
      ],
      "outcome": [
        {
          "collectionName": "coll0",
          "databaseName": "crud-tests",
          "documents": [
            {
              "_id": 1,
              "$a": 1
            }
          ]
        }
      ]
    },
    {
      "description": "Inserting document with top-level dollar-prefixed key on pre-5.0 server yields server-side error",
      "runOnRequirements": [
        {
          "maxServerVersion": "4.99"
        }
      ],
      "operations": [
        {
          "name": "insertOne",
          "object": "collection0",
          "arguments": {
            "document": {
              "_id": 1,
              "$a": 1
            }
          },
          "expectError": {
            "isClientError": false
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client0",
          "events": [
            {
              "commandStartedEvent": {
                "command": {
                  "insert": "coll0",
                  "documents": [
                    {
                      "_id": 1,
                      "$a": 1
                    }
                  ]
                }
              }
            }
          ]
        }
      ],
      "outcome": [
        {
          "collectionName": "coll0",
          "databaseName": "crud-tests",
          "documents": []
        }
      ]
    },
    {
      "description": "Inserting document with top-level dotted key",
      "operations": [
        {
          "name": "insertOne",
          "object": "collection0",
          "arguments": {
            "document": {
              "_id": 1,
              "a.b": 1
            }
          },
          "expectResult": {
            "$$unsetOrMatches": {
              "insertedId": {
                "$$unsetOrMatches": 1
              }
            }
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client0",
          "events": [
            {
              "commandStartedEvent": {
                "command": {
                  "insert": "coll0",
                  "documents": [
                    {
                      "_id": 1,
                      "a.b": 1
                    }
                  ]
                }
              }
            }
          ]
        }
      ],
      "outcome": [
        {
          "collectionName": "coll0",
          "databaseName": "crud-tests",
          "documents": [
            {
              "_id": 1,
              "a.b": 1
            }
          ]
        }
      ]
    },
    {
      "description": "Inserting document with dollar-prefixed key in embedded doc",
      "operations": [
        {
          "name": "insertOne",
          "object": "collection0",
          "arguments": {
            "document": {
              "_id": 1,
              "a": {
                "$b": 1
              }
            }
          },
          "expectResult": {
            "$$unsetOrMatches": {
              "insertedId": {
                "$$unsetOrMatches": 1
              }
            }
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client0",
          "events": [
            {
              "commandStartedEvent": {
                "command": {
                  "insert": "coll0",
                  "documents": [
                    {
                      "_id": 1,
                      "a": {
                        "$b": 1
                      }
                    }
                  ]
                }
              }
            }
          ]
        }
      ],
      "outcome": [
        {
          "collectionName": "coll0",
          "databaseName": "crud-tests",
          "documents": [
            {
              "_id": 1,
              "a": {
                "$b": 1
              }
            }
          ]
        }
      ]
    },
    {
      "description": "Inserting document with dotted key in embedded doc",
      "operations": [
        {
          "name": "insertOne",
          "object": "collection0",
          "arguments": {
            "document": {
              "_id": 1,
              "a": {
                "b.c": 1
              }
            }
          },
          "expectResult": {
            "$$unsetOrMatches": {
              "insertedId": {
                "$$unsetOrMatches": 1
              }
            }
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client0",
          "events": [
            {
              "commandStartedEvent": {
                "command": {
                  "insert": "coll0",
                  "documents": [
                    {
                      "_id": 1,
                      "a": {
                        "b.c": 1
                      }
                    }
                  ]
                }
              }
            }
          ]
        }
      ],
      "outcome": [
        {
          "collectionName": "coll0",
          "databaseName": "crud-tests",
          "documents": [
            {
              "_id": 1,
              "a": {
                "b.c": 1
              }
            }
          ]
        }
      ]
    },
    {
      "description": "Inserting document with dollar-prefixed key in _id yields server-side error",
      "operations": [
        {
          "name": "insertOne",
          "object": "collection0",
          "arguments": {
            "document": {
              "_id": {
                "$a": 1
              }
            }
          },
          "expectError": {
            "isClientError": false
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client0",
          "events": [
            {
              "commandStartedEvent": {
                "command": {
                  "insert": "coll0",
                  "documents": [
                    {
                      "_id": {
                        "$a": 1
                      }
                    }
                  ]
                }
              }
            }
          ]
        }
      ],
      "outcome": [
        {
          "collectionName": "coll0",
          "databaseName": "crud-tests",
          "documents": []
        }
      ]
    },
    {
      "description": "Inserting document with dotted key in _id on 3.6+ server",
      "runOnRequirements": [
        {
          "minServerVersion": "3.6"
        }
      ],
      "operations": [
        {
          "name": "insertOne",
          "object": "collection0",
          "arguments": {
            "document": {
              "_id": {
                "a.b": 1
              }
            }
          },
          "expectResult": {
            "$$unsetOrMatches": {
              "insertedId": {
                "$$unsetOrMatches": {
                  "a.b": 1
                }
              }
            }
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client0",
          "events": [
            {
              "commandStartedEvent": {
                "command": {
                  "insert": "coll0",
                  "documents": [
                    {
                      "_id": {
                        "a.b": 1
                      }
                    }
                  ]
                }
              }
            }
          ]
        }
      ],
      "outcome": [
        {
          "collectionName": "coll0",
          "databaseName": "crud-tests",
          "documents": [
            {
              "_id": {
                "a.b": 1
              }
            }
          ]
        }
      ]
    },
    {
      "description": "Inserting document with dotted key in _id on pre-3.6 server yields server-side error",
      "runOnRequirements": [
        {
          "maxServerVersion": "3.4.99"
        }
      ],
      "operations": [
        {
          "name": "insertOne",
          "object": "collection0",
          "arguments": {
            "document": {
              "_id": {
                "a.b": 1
              }
            }
          },
          "expectError": {
            "isClientError": false
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client0",
          "events": [
            {
              "commandStartedEvent": {
                "command": {
                  "insert": "coll0",
                  "documents": [
                    {
                      "_id": {
                        "a.b": 1
                      }
                    }
                  ]
                }
              }
            }
          ]
        }
      ],
      "outcome": [
        {
          "collectionName": "coll0",
          "databaseName": "crud-tests",
          "documents": []
        }
      ]
    },
    {
      "description": "Inserting document with DBRef-like keys",
      "operations": [
        {
          "name": "insertOne",
          "object": "collection0",
          "arguments": {
            "document": {
              "_id": 1,
              "a": {
                "$db": "foo"
              }
            }
          },
          "expectResult": {
            "$$unsetOrMatches": {
              "insertedId": {
                "$$unsetOrMatches": 1
              }
            }
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client0",
          "events": [
            {
              "commandStartedEvent": {
                "command": {
                  "insert": "coll0",
                  "documents": [
                    {
                      "_id": 1,
                      "a": {
                        "$db": "foo"
                      }
                    }
                  ]
                }
              }
            }
          ]
        }
      ],
      "outcome": [
        {
          "collectionName": "coll0",
          "databaseName": "crud-tests",
          "documents": [
            {
              "_id": 1,
              "a": {
                "$db": "foo"
              }
            }
          ]
        }
      ]
    },
    {
      "description": "Unacknowledged write using dollar-prefixed or dotted keys may be silently rejected on pre-5.0 server",
      "runOnRequirements": [
        {
          "maxServerVersion": "4.99"
        }
      ],
      "operations": [
        {
          "name": "insertOne",
          "object": "collection1",
          "arguments": {
            "document": {
              "_id": {
                "$a": 1
              }
            }
          },
          "expectResult": {
            "$$unsetOrMatches": {
              "acknowledged": {
                "$$unsetOrMatches": false
              }
            }
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client0",
          "events": [
            {
              "commandStartedEvent": {
                "command": {
                  "insert": "coll1",
                  "documents": [
                    {
                      "_id": {
                        "$a": 1
                      }
                    }
                  ],
                  "writeConcern": {
                    "w": 0
                  }
                }
              }
            }
          ]
        }
      ],
      "outcome": [
        {
          "collectionName": "coll0",
          "databaseName": "crud-tests",
          "documents": []
        }
      ]
    }
  ]
}
