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

positional operator element mismatch when using both $slice and $ projections

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 2.4.8, 2.6.4, 2.7.6
    • Fix Version/s: 4.3.2
    • Component/s: Querying
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Steps To Reproduce:
      Hide

      You insert a document with two array fields:

      db.test.insert( { "importing" : [ { "foo": "a" }, { "foo": "b" } ], "jobs" : [ { "status" : "completed" } ] } )

      You try to query it, where you use $slice on one, and $ on another. The query should match the second element in importing, which does not exist in jobs:

      db.test.find( { "importing.foo": "b" }, { jobs: { '$slice': -1 }, 'importing.$': 1 })

      You get:

      error: { "$err" : "positional operator element mismatch", "code" : 16353 }

      Show
      You insert a document with two array fields: db.test.insert( { "importing" : [ { "foo": "a" }, { "foo": "b" } ], "jobs" : [ { "status" : "completed" } ] } ) You try to query it, where you use $slice on one, and $ on another. The query should match the second element in importing, which does not exist in jobs: db.test.find( { "importing.foo": "b" }, { jobs: { '$slice': -1 }, 'importing.$': 1 }) You get: error: { "$err" : "positional operator element mismatch", "code" : 16353 }
    • Sprint:
      Query 2019-11-18, Query 2019-12-02

      Description

      It is not possible to use both $slice and $ projections, even if they are on separate fields.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              ian.boros Ian Boros
              Reporter:
              mitar Mitar
              Participants:
              Votes:
              1 Vote for this issue
              Watchers:
              9 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: