Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-543

Update of nonexistent record not throwing exception

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

      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 Unassigned
            Reporter:
            holysamosa Jeremy Johnson
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: