[SERVER-26960] Consider improving error message when attempting $natural sort on a view Created: 09/Nov/16  Updated: 05/Apr/17  Resolved: 09/Dec/16

Status: Closed
Project: Core Server
Component/s: Diagnostics
Affects Version/s: None
Fix Version/s: 3.4.2, 3.5.1

Type: Improvement Priority: Major - P3
Reporter: Kyle Suarez Assignee: Kyle Suarez
Resolution: Done Votes: 0
Labels: read-only-views
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Related
is related to SERVER-27492 Support $natural sorts on views Closed
Backwards Compatibility: Fully Compatible
Backport Completed:
Backport Requested:
v3.4
Sprint: Query 2016-12-12, Query 2017-01-23
Participants:

 Description   

It's currently not possible to use $natural in aggregation to force a "natural sort order". However, if a user attempts a $natural sort when running the find command on a view, they'll get this fairly unnatural-looking error message:

> db.view.find().sort( { $natural: 1 } )
Error: error: {
        "ok" : 0,
        "errmsg" : "FieldPath field names may not start with '$'.",
        "code" : 16410,
        "codeName" : "Location16410"
}

We should consider whether or not to detect this up-front in order to produce a clearer error message for the user.



 Comments   
Comment by Githook User [ 21/Dec/16 ]

Author:

{u'username': u'ksuarz', u'name': u'Kyle Suarez', u'email': u'kyle.suarez@mongodb.com'}

Message: SERVER-26960 don't convert find to aggregation if sort contains $natural

(cherry picked from commit 5e7713bd86268e8a2ad4a1e41219401103681060)
Branch: v3.4
https://github.com/mongodb/mongo/commit/c3d4dd1576d63df1200b09895c3bb4fb281fc0f6

Comment by Kyle Suarez [ 09/Dec/16 ]

david.storch, I'm requesting backport to 3.4, but I leave the decision to you.

Comment by Githook User [ 09/Dec/16 ]

Author:

{u'username': u'ksuarz', u'name': u'Kyle Suarez', u'email': u'kyle.suarez@mongodb.com'}

Message: SERVER-26960 don't convert find to aggregation if sort contains $natural
Branch: master
https://github.com/mongodb/mongo/commit/5e7713bd86268e8a2ad4a1e41219401103681060

Generated at Thu Feb 08 04:13:44 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.