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

$addToSet with $each doesn't check uniqueness for new elements

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 1.7.3
    • Fix Version/s: 1.7.4
    • Component/s: Write Ops
    • Labels:
      None
    • Environment:
      linux ubuntu 10.10
    • Operating System:
      ALL

      Description

      ------------------------------------------------------------------------------
      $ cat test_case.rb

      require 'mongo'

      db = Mongo::Connection.new.db('sample-db')
      coll = db.collection('test')
      coll.remove

      coll.insert({:_id => "test_add_to_set", :arr => []})
      coll.update({:_id => "test_add_to_set"}, {:$addToSet => {:arr => {:$each => [1,1,2,3]}}})

      puts coll.find({:_id => "test_add_to_set"}).next_document.inspect

      $ ruby test_case.rb

      {"_id"=>"test_add_to_set", "arr"=>[1, 1, 2, 3]}

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

      for some reason the value(1) in the array is repeated

      is this a bug? or am I doing something wrong?

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: