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

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

    • Type: Icon: Bug Bug
    • Resolution: Gone away
    • Priority: Icon: Minor - P4 Minor - P4
    • 1.34.0
    • Affects Version/s: 1.25.0
    • Component/s: Query Bar
    • None
    • 3
    • Not Needed

      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".

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

              Created:
              Updated:
              Resolved: