{
  "description": "updateMany-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"
      }
    }
  ],
  "initialData": [
    {
      "collectionName": "coll0",
      "databaseName": "crud-tests",
      "documents": [
        {
          "_id": 1,
          "foo": {}
        }
      ]
    }
  ],
  "tests": [
    {
      "description": "Updating document to set top-level dollar-prefixed key on 5.0+ server",
      "runOnRequirements": [
        {
          "minServerVersion": "5.0"
        }
      ],
      "operations": [
        {
          "name": "updateMany",
          "object": "collection0",
          "arguments": {
            "filter": {
              "_id": 1
            },
            "update": [
              {
                "$replaceWith": {
                  "$setField": {
                    "field": {
                      "$literal": "$a"
                    },
                    "value": 1,
                    "input": "$$ROOT"
                  }
                }
              }
            ]
          },
          "expectResult": {
            "matchedCount": 1,
            "modifiedCount": 1,
            "upsertedCount": 0
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client0",
          "events": [
            {
              "commandStartedEvent": {
                "command": {
                  "update": "coll0",
                  "updates": [
                    {
                      "q": {
                        "_id": 1
                      },
                      "u": [
                        {
                          "$replaceWith": {
                            "$setField": {
                              "field": {
                                "$literal": "$a"
                              },
                              "value": 1,
                              "input": "$$ROOT"
                            }
                          }
                        }
                      ],
                      "multi": true,
                      "upsert": {
                        "$$unsetOrMatches": false
                      }
                    }
                  ]
                }
              }
            }
          ]
        }
      ],
      "outcome": [
        {
          "collectionName": "coll0",
          "databaseName": "crud-tests",
          "documents": [
            {
              "_id": 1,
              "foo": {},
              "$a": 1
            }
          ]
        }
      ]
    },
    {
      "description": "Updating document to set top-level dotted key on 5.0+ server",
      "runOnRequirements": [
        {
          "minServerVersion": "5.0"
        }
      ],
      "operations": [
        {
          "name": "updateMany",
          "object": "collection0",
          "arguments": {
            "filter": {
              "_id": 1
            },
            "update": [
              {
                "$replaceWith": {
                  "$setField": {
                    "field": {
                      "$literal": "a.b"
                    },
                    "value": 1,
                    "input": "$$ROOT"
                  }
                }
              }
            ]
          },
          "expectResult": {
            "matchedCount": 1,
            "modifiedCount": 1,
            "upsertedCount": 0
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client0",
          "events": [
            {
              "commandStartedEvent": {
                "command": {
                  "update": "coll0",
                  "updates": [
                    {
                      "q": {
                        "_id": 1
                      },
                      "u": [
                        {
                          "$replaceWith": {
                            "$setField": {
                              "field": {
                                "$literal": "a.b"
                              },
                              "value": 1,
                              "input": "$$ROOT"
                            }
                          }
                        }
                      ],
                      "multi": true,
                      "upsert": {
                        "$$unsetOrMatches": false
                      }
                    }
                  ]
                }
              }
            }
          ]
        }
      ],
      "outcome": [
        {
          "collectionName": "coll0",
          "databaseName": "crud-tests",
          "documents": [
            {
              "_id": 1,
              "foo": {},
              "a.b": 1
            }
          ]
        }
      ]
    },
    {
      "description": "Updating document to set dollar-prefixed key in embedded doc on 5.0+ server",
      "runOnRequirements": [
        {
          "minServerVersion": "5.0"
        }
      ],
      "operations": [
        {
          "name": "updateMany",
          "object": "collection0",
          "arguments": {
            "filter": {
              "_id": 1
            },
            "update": [
              {
                "$set": {
                  "foo": {
                    "$setField": {
                      "field": {
                        "$literal": "$a"
                      },
                      "value": 1,
                      "input": "$foo"
                    }
                  }
                }
              }
            ]
          },
          "expectResult": {
            "matchedCount": 1,
            "modifiedCount": 1,
            "upsertedCount": 0
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client0",
          "events": [
            {
              "commandStartedEvent": {
                "command": {
                  "update": "coll0",
                  "updates": [
                    {
                      "q": {
                        "_id": 1
                      },
                      "u": [
                        {
                          "$set": {
                            "foo": {
                              "$setField": {
                                "field": {
                                  "$literal": "$a"
                                },
                                "value": 1,
                                "input": "$foo"
                              }
                            }
                          }
                        }
                      ],
                      "multi": true,
                      "upsert": {
                        "$$unsetOrMatches": false
                      }
                    }
                  ]
                }
              }
            }
          ]
        }
      ],
      "outcome": [
        {
          "collectionName": "coll0",
          "databaseName": "crud-tests",
          "documents": [
            {
              "_id": 1,
              "foo": {
                "$a": 1
              }
            }
          ]
        }
      ]
    },
    {
      "description": "Updating document to set dotted key in embedded doc on 5.0+ server",
      "runOnRequirements": [
        {
          "minServerVersion": "5.0"
        }
      ],
      "operations": [
        {
          "name": "updateMany",
          "object": "collection0",
          "arguments": {
            "filter": {
              "_id": 1
            },
            "update": [
              {
                "$set": {
                  "foo": {
                    "$setField": {
                      "field": {
                        "$literal": "a.b"
                      },
                      "value": 1,
                      "input": "$foo"
                    }
                  }
                }
              }
            ]
          },
          "expectResult": {
            "matchedCount": 1,
            "modifiedCount": 1,
            "upsertedCount": 0
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client0",
          "events": [
            {
              "commandStartedEvent": {
                "command": {
                  "update": "coll0",
                  "updates": [
                    {
                      "q": {
                        "_id": 1
                      },
                      "u": [
                        {
                          "$set": {
                            "foo": {
                              "$setField": {
                                "field": {
                                  "$literal": "a.b"
                                },
                                "value": 1,
                                "input": "$foo"
                              }
                            }
                          }
                        }
                      ],
                      "multi": true,
                      "upsert": {
                        "$$unsetOrMatches": false
                      }
                    }
                  ]
                }
              }
            }
          ]
        }
      ],
      "outcome": [
        {
          "collectionName": "coll0",
          "databaseName": "crud-tests",
          "documents": [
            {
              "_id": 1,
              "foo": {
                "a.b": 1
              }
            }
          ]
        }
      ]
    }
  ]
}
