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

    • Bug
    • Status: Closed
    • Minor - P4
    • Resolution: Fixed
    • None
    • 2.5.5
    • Querying
    • MacOSX
    • ALL
    • 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

        1. server10416.js
          0.3 kB
          Benety Goh

        Issue Links

          Activity

            People

              benety.goh@mongodb.com Benety Goh
              liquidg3 Taylor Romero
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: