Uploaded image for project: 'MongoDB Database Tools'
  1. MongoDB Database Tools
  2. TOOLS-2175

MongoImport Upsert doesn't work for empty arrays

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Cannot Reproduce
    • 3.6.9
    • None
    • mongoimport
    • None

    Description

      Insert a new document in MongoDB

      Example:

      db.collection.insert({"type":"Test","uid":"sampleUID", "items":[]})
      

      Use mongoimport tool to import a JSON  file (test.json) which has a record for the same sampleUID and type Test

      {"type":"Test","uid":"sampleUID", "items":[{"itemId":"1234","itemId":"4444"]}

       
      mongoimport --db dbName -c collectionName --mode upsert --upsertFields uid,type --type json --file test.json
      

       

      Result:

      Two documents present in MongoDB for the same uid and type

      {"_id" : ObjectId("5b6c3df492edb6fcb616feb7"),"type":"Test","uid":"sampleUID", "items":[{"itemId":"1234","itemId":"4444"]}
       
      {"_id" : ObjectId("5b6c3df492edb6fcb616feb6"),"type":"Test","uid":"sampleUID", "items":[]}
      

      Expected:

      This was an upsert operation, so the original empty list should have been updated instead of creating a new list

       

      Attachments

        Activity

          People

            daniel.hatcher@mongodb.com Danny Hatcher (Inactive)
            lakshmi1234 Lakshmi Madhavarao
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: