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

Relax a restriction on exclusion of a field in inclusion projection

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Works as Designed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Query Planning
    • Labels:
      None
    • Operating System:
      ALL

      Description

      This restriction is counter-intuitive and makes little sense:

      <field>:<0 or false> Specifies the exclusion of a field.
      To exclude a field conditionally, use the REMOVE variable instead. For details, see Exclude Fields Conditionally.
      If you specify the exclusion of a field other than _id, you cannot employ any other $project specification forms. This restriction does not apply to conditionally exclusion of a field using the REMOVE variable.
      See also the $unset stage to exclude fields.

       

      > db.sample2.aggregate([{$project: {i1:1, str1:0}}])
      Error: command failed: {
      	"ok" : 0,
      	"errmsg" : "Invalid $project :: caused by :: Cannot do exclusion on field str1 in inclusion projection",
      	"code" : 31254,
      ...

       

        Attachments

          Activity

            People

            Assignee:
            backlog-query-optimization Backlog - Query Optimization
            Reporter:
            ruslan.abdulkhalikov Ruslan Abdulkhalikov
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: