[COMPASS-3552] Compass Aggregation Builder gives "n.map is not a function" error for valid MongoShell / PyMongo aggregation Created: 05/Apr/19  Updated: 29/Oct/23  Resolved: 26/Apr/19

Status: Closed
Project: Compass
Component/s: Aggregation pipeline
Affects Version/s: 1.17.0
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Eoin Brazil Assignee: Alena Khineika
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File screenshot_549.png     PNG File screenshot_550.png    
Issue Links:
Related
is related to COMPASS-3485 $expr query is not valid Closed
Sprint: Iteration Bison, Iteration Cat

 Description   

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


Generated at Wed Feb 07 22:33:32 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.