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

Update of nonexistent record not throwing exception

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Works as Designed
    • Affects Version/s: 2.7.2
    • Fix Version/s: None
    • Component/s: API
    • Labels:

      Description

      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?

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved: