[SERVER-12959] v2.6.0-rc0 update $position - slightly incorrect error message Created: 28/Feb/14  Updated: 22/Feb/16  Resolved: 03/Feb/16

Status: Closed
Project: Core Server
Component/s: Write Ops
Affects Version/s: 2.6.0-rc0, 2.6.11, 3.2.1, 3.3.1
Fix Version/s: 3.3.2

Type: Improvement Priority: Trivial - P5
Reporter: Roman Kuzmin Assignee: James Wahlin
Resolution: Done Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Participants:

 Description   

This update

> db.test.update({x : 1}, {$push : {a : {$each : [3,4], $position : -1}}})
WriteResult({
        "nMatched" : 0,
        "nUpserted" : 0,
        "nModified" : 0,
        "writeError" : {
                "code" : 2,
                "errmsg" : "The $position value in $push must be positive."
        }
})

correctly fails with the message "The $position value in $push must be positive.". The message is slightly incorrect though because valid values are positive and 0 (non negative).



 Comments   
Comment by Githook User [ 03/Feb/16 ]

Author:

{u'username': u'jbreams', u'name': u'Jonathan Reams', u'email': u'jbreams@mongodb.com'}

Message: SERVER-12959 fix lint
Branch: master
https://github.com/mongodb/mongo/commit/7ee4cc1c5b946d9855fef217f8293216e954fd53

Comment by Githook User [ 03/Feb/16 ]

Author:

{u'username': u'jameswahlin', u'name': u'James Wahlin', u'email': u'james.wahlin@10gen.com'}

Message: SERVER-12959 Fix $position error message on invalid value
Branch: master
https://github.com/mongodb/mongo/commit/594a3f4ddc3d2d9dd18b16682cd53881a94fb238

Comment by Roman Kuzmin [ 28/Feb/14 ]

The same defect exists in error messages for other invalid $position values, e.g. for null, string:

'The value for $position must be a positive numeric value not a NULL'.
'The value for $position must be a positive numeric value not a String'

Generated at Thu Feb 08 03:30:12 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.