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

$addToSet can cause upsert to fail

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.3.3
    • Affects Version/s: 1.3.2
    • Component/s: Write Ops
    • None

      $addToSet seems to cause an upsert to fail when the document doesn't exist (i.e. it fails to insert).

      When using $push the document is correctly inserted. For example (perl):

      $col->update(

      { '_id' => '123' },
      {
      '$push' => { 'tags' => 'foo' },
      },
      { 'upsert' => 1, }
      );

      (where the document id 123 doesn't yet exist) creates:
      {
      _id => 123,
      tags => [ 'foo' ],
      }

      which is nice! but the $addToSet equivalent fails to insert anything:

      $col->update(
      { '_id' => '123' }

      ,
      {
      '$addToSet' =>

      { 'tags' => 'foo' }

      ,
      },

      { 'upsert' => 1, }

      );

      It would be great if it could work the same...

            Assignee:
            eliot Eliot Horowitz (Inactive)
            Reporter:
            abryan17 Andrew Bryan
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: