[SERVER-31977] Inconsistent treatment of numerical path components between query and update Created: 15/Nov/17  Updated: 06/Dec/22

Status: Backlog
Project: Core Server
Component/s: Querying, Write Ops
Affects Version/s: 3.4.10, 3.6.0-rc4
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Tess Avitabile (Inactive) Assignee: Backlog - Query Optimization
Resolution: Unresolved Votes: 0
Labels: mql-semantics, query-44-grooming
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Query Optimization
Operating System: ALL
Participants:

 Description   

In the query language, when a numerical path component is used to select an element of an array, elements are only selected if the numerical path component matches their exact fieldname:

> db.c.insert({_id: 0, a: [0]})
WriteResult({ "nInserted" : 1 })
> db.c.find({"a.00": 0})
> db.c.find({"a.0": 0})
{ "_id" : 0, "a" : [ 0 ] }

In the update language, a numerical path components is parsed as an unsigned base 10 integer n, and we select the nth array element:

> db.c.insert({_id: 0, a: [0]})
WriteResult({ "nInserted" : 1 })
> db.c.update({_id: 0}, {$set: {"a.00": 1}})
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
> db.c.find()
{ "_id" : 0, "a" : [ 1 ] }


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