[COMPASS-4435] Aggregations with sort operations aren't respected when saved as a view Created: 06/Oct/20  Updated: 29/Oct/23  Resolved: 18/Nov/20

Status: Closed
Project: Compass
Component/s: Compass, CRUD
Affects Version/s: 1.22.1
Fix Version/s: 1.24.1

Type: Bug Priority: Minor - P4
Reporter: David May Assignee: Anna Henningsen
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

macOS Catalina 10.15.7
docker image: mongo:4
400 Documents


Attachments: PNG File Screen Shot 2020-10-06 at 11.48.36 PM.png     PNG File Screen Shot 2020-10-06 at 11.50.01 PM.png    
Story Points: 1
Documentation Changes: Not Needed
Sprint: Iteration Quince

 Description   

Take this sample pipeline:

[
  {
    '$sort': {
      'date.dates': -1
    }
  }, {
    '$project': {
      'code': '$code.label', 
      'companyName': '$company.label', 
      'announcement': '$title.label', 
      'announcementLink': {
        '$arrayElemAt': [
          '$title.links', 0
        ]
      }, 
      'date': {
        '$arrayElemAt': [
          '$date.dates', 0
        ]
      }, 
      'announcementType': '$type.label', 
      'announcementDetail': '$announcementDetail', 
      'announcementDocuments': '$announcementDocuments', 
      'md5': '$md5'
    }
  }
]

 

I'm finding that on this particular version of Compass it seems that when this pipeline is saved as a view. The sorting that should be applied simply isn't. No errors, no reason why... as a workaround, I have to add manually add {date: -1} to the sort field when viewing the view's documents.

I've noticed that this is also happening when connecting to our production servers as well.

 



 Comments   
Comment by Githook User [ 19/Nov/20 ]

Author:

{'name': 'Anna Henningsen', 'email': 'anna.henningsen@mongodb.com', 'username': 'addaleax'}

Message: fix(compass-crud): do not explicitly sort by _id COMPASS-4435 (#2059)

Brings in:

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