Uploaded image for project: 'Compass '
  1. Compass
  2. COMPASS-3552

Compass Aggregation Builder gives "n.map is not a function" error for valid MongoShell / PyMongo aggregation

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 1.17.0
    • Component/s: Aggregation pipeline
    • None
    • Iteration Bison, Iteration Cat

      Hi All,

      I'm not sure if I'm missing something but I keep having issues with getting the Aggregation Builder in Compass to generate a new stage for a workshop I'm working.

      Specifically, it seems not to process the $match below:

      no_empty_tab_maps = {
         "$match": {
             "$expr": { "$gt": [ { "$size": { "$objectToArray": "$tab_map" } }, 0 ] }
         }
      }
      

      or this (when using the "copied from text" functionality")

      {
         $match: {
             $expr: { $gt: [ { $size: { $objectToArray: "$tab_map" } }, 0 ] }
         }
      }
      

      The error it returns is "n.map is not a function" is returned in all cases.

      Here's a sample document (MongoShell syntax):

      db.my_coll.insertOne({
        "user_id": 1,
        "offering": "M036/2017_November",
        "tab_map": {
          "_cls": "HgStudentAttemptableProblem",
          "id": "5a1c7e44f62672abf36e4ba3",
          "given_credit": false,
          "attempts": [
            {
              "_cls": "HgCheckAllThatApplyAttempt",
              "date": "2017-11-27 21:40:17",
              "git_stamp": {
                "date": "2017-11-27 21:40:11",
                "revision": "789c694b49dd6d7dfbb245af7ab71bf509b0ba38"
              },
              "indices": [
                1,
                0
              ]
            },
            {
              "_cls": "HgCheckAllThatApplyAttempt",
              "date": "2017-11-29 14:55:01",
              "git_stamp": {
                "date": "2017-11-29 14:54:52",
                "revision": "94556bc6f03ac374a48e4df79808b8b059c806e7"
              },
              "indices": [
                3,
                2
              ]
            }
          ]
        }
      })
      

      Am I missing something ? Is the tab_map underscore causing an issue with the variable name ? Is this an existing bug and is there a known workaround ? I've tried it on 1.17.0 and on 1.18 latest beta builds.

      Thanks!
      Eoin

        1. screenshot_550.png
          screenshot_550.png
          171 kB
        2. screenshot_549.png
          screenshot_549.png
          141 kB

            Assignee:
            alena.khineika@mongodb.com Alena Khineika
            Reporter:
            eoin.brazil@mongodb.com Eoin Brazil
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: