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

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

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.7.4
    • Affects Version/s: 1.7.3
    • Component/s: Write Ops
    • None
    • Environment:
      linux ubuntu 10.10
    • ALL

      ------------------------------------------------------------------------------
      $ 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?

            Assignee:
            Unassigned Unassigned
            Reporter:
            david.cuadrado David Cuadrado
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: