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

Cannot project embedded object field names prefixed with dollar sign

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 2.2.1
    • Component/s: Querying
    • None
    • Query
    • ALL

      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.

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

              Created:
              Updated:
              Resolved: