Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-282

Empty UpdateBuilder will null out a document

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • 1.2
    • 1.1
    • None
    • None
    • Windows Server 2008
    • Minor Change

    Description

      Using the code below, if a call is made to class method Handle() with an evnt with out any Changes this will pass an initialized but empty UpdateBuilder() to the MongoCollection Update command which will null out all the values in the document. I was expecting no changes to be made.

      public class xyz
      {
      readonly MongoCollection<T> _docs;

      public void Update(dynamic id, IMongoUpdate update)

      { _docs.Update(new QueryDocument("_id", id), update); }

      }

      public class abc
      {
      readonly xyz _atttributeTypes;

      public void Handle(AttributeTypeUpdated evnt)

      { var update = new UpdateBuilder(); foreach (var change in evnt.Changes) update.SetWrapped(change.Key, change.Value); _atttributeTypes.Update(evnt.EventSourceId, update); }

      }

      Attachments

        Activity

          People

            robert@mongodb.com Robert Stam
            woaksie John Woakes
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: