[SERVER-29912] $pop update modifier should validate that its argument is either 1 or -1 Created: 28/Jun/17  Updated: 30/Oct/23  Resolved: 05/Jul/17

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: 3.5.10

Type: Improvement Priority: Major - P3
Reporter: David Storch Assignee: David Storch
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-28769 Create PopNode Closed
Documented
is documented by DOCS-10521 Docs for SERVER-29912: $pop update mo... Closed
Backwards Compatibility: Minor Change
Sprint: Query 2017-07-10
Participants:

 Description   

In 3.6.x versions, the argument to the $pop mode will be validated more strictly once the featureCompatibilityVersion is set to "3.6".

Old behavior

The past behavior was that any BSON element was allowed in place of elt below:

db.collection.update({}, {$pop: {"array": <elt>}});

If <elt> was numeric and less than zero, then the $pop would remove the first element of the array. On the other hand, if <elt> was any non-numeric type or was a number greater than or equal to zero, $pop would remove the last element of the array.

New behavior

$pop will now fail at parse time if elt is either a non-numeric type, or is a number which is not equal to 1 or -1. All numeric BSON types are allowed (NumberInt, NumberLong, NumberDouble, NumberDecimal), but if the number is not an exact representation of 1 or -1, then $pop will fail to parse.



 Comments   
Comment by Githook User [ 05/Jul/17 ]

Author:

{u'username': u'dstorch', u'name': u'David Storch', u'email': u'david.storch@10gen.com'}

Message: SERVER-29912 Require argument to $pop to be 1 or -1.
Branch: master
https://github.com/mongodb/mongo/commit/2f5f2f851a37a99b4b6e1cbcbf8826183777ab1c

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