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

Unable to use BSON serializer/deserializer in a nested namespace

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major - P3 Major - P3
    • None
    • None
    • None
    • None
    • Service Arch

    Description

      Given an IDL defined in the namespace mongo (i.e. set to global.cpp_namespace) that defines a customer type with the serializer/deserializer functions in a nested namespace (e.g., mongo::util), the generated code doesn't take into account the specified namespace for the serializer/deserializer functions, causing a symbol not found error at compiling time.

      More in details, given the following IDL:

      global:
          cpp_namespace: "mongo"
      ...
       
      types:
          status:
              bson_serialization_type: any
              cpp_type: "mongo::Status"
              serializer: "mongo::util::serializeStatusToBSON"
              deserializer: "mongo::util::deserializeStatusFromBSON"
      ...
       
      structs:
          CoordinatorMetadata
          ...
          fields:
              error:
                  type: status

      The compiler generates the following code:

      namespace mongo {
      ...
       
      void CoordinatorMetadata::serialize(BSONObjBuilder* builder) const {
      ...
          if (_error) {
              serializeStatusToBSON((*_error), kErrorFieldName, builder);
          }
      ...
      }}

      The problem is that the function serializeStatusToBSON is defined in the namespace mongo::util, not in mongo.

      Attachments

        Activity

          People

            backlog-server-servicearch Backlog - Service Architecture
            antonio.fuschetto@mongodb.com Antonio Fuschetto
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: