-
Type: Improvement
-
Resolution: Unresolved
-
Priority: 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.
- is depended on by
-
SERVER-95210 Setting fleCompactionOptions while in FCV 7.x must disallow unknown fields
- Blocked