$addToSet can cause upsert to fail

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • 1.3.3
    • Affects Version/s: 1.3.2
    • Component/s: Write Ops
    • None
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • 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 Horowitz (Inactive)
              Reporter:
              Andrew Bryan
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved: