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

Positional projection ($) only considers first path component when comparing to query document

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 4.0.9
    • Fix Version/s: 4.3.3
    • Component/s: None
    • Backwards Compatibility:
      Minor Change
    • Operating System:
      ALL
    • Sprint:
      Query 2019-12-02, Query 2019-12-16
    • Linked BF Score:
      0

      Description

      Using a non-matching subfield (e.g., query: fieldExists.something: 1 projection: fieldExists.fieldDoesntExist.$) with the $ projection operator does not return the Positional projection 'fieldExists.fieldDoesntExist.$' does not match the query document error.
       
      Given the document:

      {
      	"_id" : ObjectId("5cb8ab2f20926051ca9e2cd7"),
      	"AOE" : [
      		{
      			"areaOfExpertise" : "aoe1",
      			"subAOE" : []
      		},
      		{
      			"areaOfExpertise" : "aoe2",
      			"subAOE" : []
      		}
      	],
      	"poolName" : "newpool",
      	"__v" : 0
      }
      

      The {"AOE.doesntExist.$":1} projection is treated the same as the correct {"AOE.$":1} projection:

      > db.proj.find({ poolName: "newpool", "AOE.areaOfExpertise": "aoe1" },{"AOE.doesntExist.$":1}).pretty()
      {
      	"_id" : ObjectId("5cb8ab2f20926051ca9e2cd7"),
      	"AOE" : [
      		{
      			"areaOfExpertise" : "aoe1",
      			"subAOE" : []
      		}
      	]
      }
      > db.proj.find({ poolName: "newpool", "AOE.areaOfExpertise": "aoe1" },{"AOE.$":1}).pretty()
      {
      	"_id" : ObjectId("5cb8ab2f20926051ca9e2cd7"),
      	"AOE" : [
      		{
      			"areaOfExpertise" : "aoe1",
      			"subAOE" : []
      		}
      	]
      }
      

        Attachments

        1. bug1.png
          bug1.png
          33 kB
        2. mongo1.png
          mongo1.png
          21 kB
        3. sub2.png
          sub2.png
          17 kB

          Issue Links

            Activity

              People

              Assignee:
              ian.boros Ian Boros
              Reporter:
              piyushkumar96 Piyush Kumar
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: