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

Distinct doesn't properly handle undefined literal

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 2.4.10, 2.6.1
    • Component/s: Querying
    • Labels:
      None
    • ALL
    • Hide
      // Setup the data.
      > t.drop()
      > t.save({a: [{b: 1}, {b: undefined}]})
      > t.save({a: {b: null}})
      
      // The array returned from distinct should have unique elements. However,
      // the output here repeats "null".
      > t.distinct("a.b")
      [ null, 1, null ]
      
      Show
      // Setup the data. > t.drop() > t.save({a: [{b: 1}, {b: undefined}]}) > t.save({a: {b: null }}) // The array returned from distinct should have unique elements. However, // the output here repeats " null " . > t.distinct( "a.b" ) [ null , 1, null ]

      There can be a repeated null element in the output array of the distinct command if a document contains a literal "undefined" element. See the repro steps for details.

      This is not a regression due to the 2.6 query engine rewrite: it affects both 2.4 and 2.6 versions.

            Assignee:
            david.storch@mongodb.com David Storch
            Reporter:
            david.storch@mongodb.com David Storch
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: