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

Filters field in compass allows for entering invalid queries and doesn't warn

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Gone away
    • Icon: Minor - P4 Minor - P4
    • 1.34.0
    • 1.25.0
    • Query Bar
    • None
    • 3
    • Not Needed

    Description

      In the Compass > Documents Modal > FILTER field, one can enter an invalid query, and Compass does not give any errors. As a result, the results shown are unexpected and inaccurate.

      For example, the following query that you specified in the Filter in Compass, qualifies neither as a find query nor as an aggregate query (there is no aggregation pipeline stage named $expr):

      {
       $expr: { $gt: [{ $toLong: "$creationDate"}, 20210512000000]}
      },
      {$group: {
      _id: {imsi:"$imsi", oldImei: "$oldImei", imei: "$imei"}, count: {$sum: 1 }
      }},
      {$match: {
        "count": {$gte : 2 }
      }},
      {$sort: {
        "count": -1
      }}
      

      Yet, when we enter the above query in the "Filter", it does not throw any errors, and returns unexpected and inaccurate results. Please refer the attached screenshot.

      Compass should warn users when an erroneous query like the above is entered in the "Filter".

      However, entering only the $expr part like the following yields the expected results, because that is correctly formed:

      { $expr: { $gt: [{ $toLong: "$creationDate"}, 20210512000000]} }
      

      Compass should warn users when an erroneous query like the above is entered in the "Filter".

      Attachments

        Activity

          People

            Unassigned Unassigned
            harshad.dhavale@mongodb.com Harshad Dhavale
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: