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

Add Query Deserialization Validation for unrecognized fields

    • Type: Icon: New Feature New Feature
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Codecs
    • Labels:
      None

      When the Mongo Java Driver deserializes BSON objects to POJOs it ignores fields that it does not recognize.

      We are interested in a new feature that would enable throwing exceptions when unknown fields are found while deserializing using the PojoCodec. There is behavior analogous to this in the .NET driver.

      It seems like there were a couple options discussed in the original POJO codec project when considering what to do when we find fields in documents that are not found in the Java POJO objects. Taken from that ticket, those were:

      1. (currently implemented) skipping that document field
      2. Throwing an exception
      3. Dumping extra fields to an optional BsonDocument on the object to hold the extra fields

      Would you all consider an implementation that would (optionally) take approach (2) or (3)? We would be interested in submitting a PR if you agree that the functionality would be useful and worth adding.

            Assignee:
            Unassigned Unassigned
            Reporter:
            evan.nixon@mongodb.com Evan Nixon
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated: