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

Cannot project embedded object field names prefixed with dollar sign

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Minor - P4 Minor - P4
    • None
    • 2.2.1
    • Querying
    • None
    • Query
    • ALL

    Description

      After SERVER-828, it's not possible to specify a field with $ in the field as part of the projection. This is likely an edge case not handled by the Projection::validateQuery() implementation here: https://github.com/mongodb/mongo/commit/fb66c84bc7bc1ece63a65766bfea2f797f3b7121

      > db.foo.drop()
      > db.foo.save({a:{$id: new ObjectId()}});
      > db.foo.find({}, {'a.$id': 1})
      error: {
      	"$err" : "Positional operator does not match the query specifier.",
      	"code" : 16354
      }

      The reproduction steps are a bit contrived, but the practical use case is a projection of the $id field of a DBRef object.

      Attachments

        Activity

          People

            backlog-server-query Backlog - Query Team (Inactive)
            jmikola@mongodb.com Jeremy Mikola
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: