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

{field: {$type:"array"}} should return documents where "field" is an array

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • 1.4.4
    • 3.5.7
    • Querying
    • None
    • Ubuntu 10.04(lucid), x64
    • Minor Change
    • ALL
    • Query 2017-05-08, Query 2017-05-29

    Description

      Operator $type does not finds array (type=4) elements.

      It tested db, 'aList' field is array. There are records with empty arrays and not empty.
      But request to count elemets by type = array brings zero (0) results;
      >db.mydata.count({ aList: {$type: 4 } }); //type = Array
      0

      Meantime, the following check shows that there are arrays, and som of them are non-empty:
      > var obj = db.mydata.count({ aList: {$type:3} }); //type = Object
      > obj
      33276

      > var zero = db.mydata.count({ aList: {$size: 0 } }); //empty arrays
      > zero
      421251
      > var all = db.mydata.count({ }); //all records
      > all
      454527
      > all - zero // number of non- empty arrays
      33276

      As you see, obj == (all - zero) - all arrays are treated as Objects(type=3)!
      Expected: array fileds should be treated as Arrays (type=4).

      Attachments

        Issue Links

          Activity

            People

              Votes:
              14 Vote for this issue
              Watchers:
              25 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: