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

$type not working properly with arrays

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Duplicate
    • Affects Version/s: 1.6.2
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Operating System:
      ALL

      Description

      > db.foo.find()

      { "_id" : ObjectId("4ca0200bfe2f0f60296390db"), "a" : 2 } { "_id" : ObjectId("4ca0200ffe2f0f60296390dc"), "a" : "3" } { "_id" : ObjectId("4ca0204afe2f0f60296390dd"), "a" : [ 1, 2, 3, 4 ] } { "_id" : ObjectId("4ca02058fe2f0f60296390de"), "a" : [ "a", "b" ] }

      Wrong:
      > db.foo.find({a : {'$type' : 1}})

      { "_id" : ObjectId("4ca0200bfe2f0f60296390db"), "a" : 2 } { "_id" : ObjectId("4ca0204afe2f0f60296390dd"), "a" : [ 1, 2, 3, 4 ] }

      (should not return the 2nd hit)

      Wrong:
      > db.foo.find({a : {'$type' : 2}})

      { "_id" : ObjectId("4ca0200ffe2f0f60296390dc"), "a" : "3" } { "_id" : ObjectId("4ca02058fe2f0f60296390de"), "a" : [ "a", "b" ] }

      (should not return the 2nd hit)

      Wrong:
      > db.foo.find({a : {'$type' : 4}})

      Returns nothing but should return the rows with the arrays.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              ajung Andreas Jung
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: