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

$lt/$lte/$gte/$gt behaves differently with array operand

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.6.0-rc0
    • Affects Version/s: 2.4.5
    • Component/s: Querying
    • Environment:
    • Major Change
    • ALL

      {$gt: [X]} matches arrays in 2.4.8 but not in 2.5.3. This is a change in the matcher behavior when the operand to the inequality operator is an array.

      In 2.4.8, the matching behavior is affected by the level of nesting of the array.

      In 2.5.3, the matcher returns zero documents as long as the element in the collection is an array.

      --------------------

      Problem:
      A two level nested array produces different results in 2.5.4

      NOTE: It appears that 2.5.4-Pre deals with this case correctly, if confirmed then this becomes a DOC tickets to list the changed behaviour.

      Reproduce:

      db.q.drop()
      db.q.insert({"c" : { "c" : [ [ [ [ ISODate("1383-05-28T00:00:00Z") ] ] ] ] }})
      db.q.insert({"c" : { "c" : [ [ [ ISODate("1383-05-28T00:00:00Z") ] ] ] }})
      db.q.insert({"c" : { "c" : [ [ ISODate("1383-05-28T00:00:00Z") ] ] }})
      db.q.insert({"c" : { "c" : [ ISODate("1383-05-28T00:00:00Z") ] }})
      db.q.find( { $nor : [ { "c.c" : { $gt : [ [ ISODate("2013-09-29T10:40Z") ] ] } } ] } )
      

      2.4.5
      Returns 3 documents, but not the [ [ value ] ]

      { "_id" : ObjectId("526fdf7c8a43120c67c8c575"), "c" : { "c" : [  [  [  [  ISODate("1383-05-28T00:00:00Z") ] ] ] ] } }
      { "_id" : ObjectId("526fdf7c8a43120c67c8c576"), "c" : { "c" : [  [  [  ISODate("1383-05-28T00:00:00Z") ] ] ] } }
      { "_id" : ObjectId("526fdf7c8a43120c67c8c578"), "c" : { "c" : [  ISODate("1383-05-28T00:00:00Z") ] } }
      

      2.5.4-Pre returns all documents

      { "_id" : ObjectId("526fdf886ca3a8357d0fe402"), "c" : { "c" : [  [  [  [  ISODate("1383-05-28T00:00:00Z") ] ] ] ] } }
      { "_id" : ObjectId("526fdf886ca3a8357d0fe403"), "c" : { "c" : [  [  [  ISODate("1383-05-28T00:00:00Z") ] ] ] } }
      { "_id" : ObjectId("526fdf886ca3a8357d0fe404"), "c" : { "c" : [  [  ISODate("1383-05-28T00:00:00Z") ] ] } }
      { "_id" : ObjectId("526fdf886ca3a8357d0fe405"), "c" : { "c" : [  ISODate("1383-05-28T00:00:00Z") ] } }
      

      It appears that 2.4.x does not deal with the [ [ value ] ] case correctly.

        1. server11444.js
          0.2 kB
          Benety Goh
        2. server11444.js
          1 kB
          Benety Goh

            Assignee:
            benety.goh@mongodb.com Benety Goh
            Reporter:
            alvin Alvin Richards (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: