Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-10416

Using a dbref in a query nested in an "$in" gives "cannot next $ under $in" error

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.5.5
    • Component/s: Querying
    • Labels:
    • Environment:
      MacOSX
    • Operating System:
      ALL
    • Steps To Reproduce:
      Hide

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

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

      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"
      }

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: