Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-95157

Retain ignored fields list when parsing IDL structs

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Server Programmability

      A situation came up where we were parsing a non-strict IDL struct, and for logging purposes we wanted to know if any unknown fields were present during the course of parsing. In this particular case, we only had the struct, we didn't have the original BSON, or we might have done our own iteration loop in the failure case.

      I'm thinking something like:

      class IDLStruct123 {
      public:
         // ...
        const std::set<StringData>& ignoredFields() const { return _ignoredFields; }
      private:
        std::set<StringData> _ignoredFields;
      };
      
      IDLStruct123 IDLStruct123::parse(...) {
         for (auto elem : obj) {
              // if knownField....
              } else {
                  _ignoredFields.insert(fieldName);
              }
          }
          // ...
      }
      

      Using a StringData view should be fine as we're bound by the same ownership rules from the originating BSONObj as the rest of the string fields (unless something has changed). So the extra weight should be limited to the std::set and its buckets. Alternately, we could require opting in to this functionality.

            Assignee:
            Unassigned Unassigned
            Reporter:
            sara.golemon@mongodb.com Sara Golemon
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: