[SERVER-10416] Using a dbref in a query nested in an "$in" gives "cannot next $ under $in" error Created: 02/Aug/13  Updated: 11/Jul/16  Resolved: 19/Nov/13

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

Type: Bug Priority: Minor - P4
Reporter: Taylor Romero Assignee: Benety Goh
Resolution: Done Votes: 0
Labels: query_triage
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

MacOSX


Attachments: File server10416.js    
Issue Links:
Duplicate
is duplicated by SERVER-11552 $in queries with dbrefs are broken on... Closed
Operating System: ALL
Steps To Reproduce:

Drop some dbrefs into a document and query against it using $in.

Participants:

 Description   

This query works in all 2.5.1 (unstable) and all stable builds:

db.roles.find({ "owner": {
	"$ref": "users",
	"$id": ObjectId("51fac2e08c0c23f6c3000046")
}});

This query does not work in 2.5.1 (unstable) but does work in all stable builds:

db.roles.find({ "owner": {
"$in": [
            {
                "$ref": "roles",
                "$id": {
                    "$id": "51fac2de8c0c23f6c3000030"
                }
            },
            {
                "$ref": "roles",
                "$id": {
                    "$id": "51fac2de8c0c23f6c3000031"
                }
            }
      ]
}});

Here is a sample document:

{
  "dateInserted": 1375388467,
  "dateUpdated": 1375388545,
  "owner": [
    {
      "$ref": "users",
      "$id": ObjectId("51fac2e08c0c23f6c3000046")
    }
  ],
  "name": "Search Manager",
  "key": "search-manager"
}



 Comments   
Comment by Githook User [ 19/Nov/13 ]

Author:

{u'username': u'benety', u'name': u'Benety Goh', u'email': u'benety@mongodb.com'}

Message: SERVER-10416 support DBRef as $in operand
Branch: master
https://github.com/mongodb/mongo/commit/7cb1def4e5a1a38792436c83ae22ace4c572c73c

Comment by Stennie Steneker (Inactive) [ 14/Aug/13 ]

Hi Taylor,

Thank you for helping test a development release of MongoDB. Your $in example was missing a closing ']' bracket, but after adding that I can confirm the exception with MongoDB 2.5.1:

error: { "$err" : "bad query: BadValue cannot next $ under $in", "code" : 16810 }

Regards,
Stephen

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