davidlatwe/montydb

Updating a document in an array leads to an error

Opened this issue · 0 comments

Updating a document in an array leads to an error:
https://docs.mongodb.com/manual/reference/operator/update/positional/#update-documents-in-an-array

  collection.update_one(
      filter={
          "order": order_number,
          "products.product_id": product_id,
      },
      update={
          "$set": {
              "products.$.quantity": quantity
          }
      }
  )

leads to an exception:

            else:
                # Replace "$" into matched array element index
                matched = fieldwalker.get_matched()
>               position = matched.split(".")[0]
E               AttributeError: 'NoneType' object has no attribute 'split'
\field_walker.py:586: AttributeError