Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-75880

Upsert permits _id values containing $-prefixed paths which cannot be inserted using insert command

    • Query Optimization
    • Minor Change
    • ALL
    • v7.0, v6.3, v6.0, v5.0
    • QO 2023-05-29, QO 2023-06-12

      This is a continuation to SERVER-75517 where the changes from 819f9d1 made it so the server checks the top-level fields within an _id embedded object do not start with a '$' character. The non top-level fields in the _id embedded object won't be validated for '$' characters by an update using upsert=true. The upsert behavior diverges from the storage_validation::storageValidIdField() / BSONObj::storageValidEmbedded() behavior called by the insert command via fixDocumentForInsert() in which the latter recursive checks that fields in embedded objects and arrays at any level do not start with a '$' character.

      This difference in behavior between [updates using upsert=true] and inserts would prevent tools like mongosync which perform a logical sync from successfully copying over the documents. Probably the documents should be prevented from being upserted to preserve the pre PM-1856 behavior for the _id field.

            Assignee:
            chii.huang@mongodb.com Chi-I Huang
            Reporter:
            max.hirschhorn@mongodb.com Max Hirschhorn
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: