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

Empty UpdateBuilder will null out a document

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.2
    • Affects Version/s: 1.1
    • Component/s: None
    • Labels:
      None
    • Environment:
      Windows Server 2008
    • Minor Change

      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); }

      }

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

              Created:
              Updated:
              Resolved: