Update of nonexistent record not throwing exception

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: 2.7.2
    • Component/s: API
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      If my collection has WriteConcern.SAFE, shouldn't trying to update( upsert=FALSE) a non-existent record throw an exception? This isn't happening in my application.

      Here's a contrived example that exhibits the behavior:

      DBCollection collection = getDb().getCollection("empty_collection");
      collection.setWriteConcern( WriteConcern.SAFE);

      collection.update( new BasicDBObject().append("_id", "doesntExist"), new BasicDBObject().append("some", "value"), false, false);

      No exception is thrown here. If this is by design, how should I test for attempts to update non-existent records?

            Assignee:
            Unassigned
            Reporter:
            Jeremy Johnson
            None
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: