Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-1460

update array items with $[]

    • Type: Icon: Task Task
    • Resolution: Cannot Reproduce
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.6
    • Component/s: Write Ops
    • None
    • Environment:
      mongodb 3.6.0
      pymongo 3.6.0
      python 2.7.10 on Mac

      following the documentation here https://docs.mongodb.com/manual/reference/operator/update/positional-all/

      I am trying to make use of $[] accessor in an update request :

      db.graph.objects.update({'$and': [{'_item': 'item://438281502040'}, {'_v': 0}]},
      {'$set': {'platforms.$[].value.idZap': '112', 'defaults.idZap': '1'}})
      

      and my request fails with the following WriteError:

      pymongo.errors.WriteError: cannot use the part (platforms of platforms.$[].value.idZap) to traverse the element ({platforms: [ { value: { genre: "Nationale", idZap: "112", csa: 1, bouquets: [ "Bouquet de base Standard et Mobile" ] }, key: "btv" }, { value: { genre: "SuperNational", idZap: "2", csa: "2", bouquets: "Bouquet Premium" }, key: "megalithe" }, { value: { genre: "Nationale", idZap: "2", csa: 1, bouquets: [ "Bouquet de base Standard" ] }, key: "xdsl" }, { value: { genre: "Nationale", idZap: "4", csa: 1, bouquets: [ "Bouquet de base " ] }, key: "miami" }, { value: { genre: "Nationale", idZap: "112", csa: 1, bouquets: [ "Bouquet de base " ] }, key: "web" } ]})
      

      has the $[] operator from mongodb 3.6.0 been made available in the python driver ?
      am I doing anything wrong?

            Assignee:
            shane.harvey@mongodb.com Shane Harvey
            Reporter:
            Hamelin Cedric [X]
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: