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

Unexpected update with pipeline result of embedded doc

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
    • Query 2021-02-08

      I have a doc in my collection which was inserted

      collection.insert_one({'obj': {'a': 1, 'c': 3})
      

      If I update it with

      collection.update_one({}, {'$set': {'obj': {'a': 1, 'b': 2, 'c': 3}}})
      

      I get {'obj': {'a': 1, 'b': 2, 'c': 3}} (same as doc update, as expected)

      But if I update it with pipeline

      collection.update_one({}, [{'$set': {'obj': {'a': 1, 'b': 2, 'c': 3}}}])
      

      I get {'obj': {'a': 1, 'c': 3, 'b': 2}} (like there are not set of obj, but set of non exist b in obj)

      If I need to update field of embedded doc, I use update with dot notation. But this full embedded doc update has unexpected behavior, therefore I created bug.

      Also I chose Python Driver project because I found it with pymongo and motor, but It can be mongo server problem. If it is, move it please.

            Assignee:
            charlie.swanson@mongodb.com Charlie Swanson
            Reporter:
            mix.ilchenko@gmail.com Mikhail Ilchenko
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: