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

Cannot project embedded object field names prefixed with dollar sign

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Gone away
    • Affects Version/s: 2.2.1
    • Fix Version/s: None
    • Component/s: Querying
    • Labels:
      None
    • Operating System:
      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

          Issue Links

            Activity

              People

              • Votes:
                2 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: