[SERVER-55642] Parsing {$ne: X} to {$not: {$eq: X}} is weird with arrays Created: 30/Mar/21  Updated: 06/Dec/22

Status: Backlog
Project: Core Server
Component/s: Query Language
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Mathias Stearn Assignee: Backlog - Query Optimization
Resolution: Unresolved Votes: 0
Labels: asya
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Query Optimization
Participants:

 Description   

> db.blah.insert({a: 'not 3'})
WriteResult({ "nInserted" : 1 })
> db.blah.insert({a: ['not 3', 3]})
WriteResult({ "nInserted" : 1 })
> db.blah.find({a: {$ne: 3}})
{ "_id" : ObjectId("60634e127cc9a947848c101a"), "a" : "not 3" }

Under the normal rules for arrays, both documents should match, since they each have at least one element in a that matches. However because we convert
{a: {$ne: X
}} to {$not: {a: {$eq: X}}} at parse time, we get the observed semantics. If people actually want that behavior, they could always type that directly.

Might not be able to fix this in MQL1.0, but probably worth keeping this in a list of things to fix for MQL2.0.


Generated at Thu Feb 08 05:37:02 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.