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

Allow IDL generator serialize custom types in arrays

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 7.2.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Fully Compatible
    • ALL
    • QE 2023-10-02, QE 2023-10-16, QE 2023-10-30, QE 2023-11-13
    • 120

      While working on PM-412 I stumbled on the issue of serializing custom defined types in arrays.

      Imagine the following idl definition:

      types: 
        IndexHint: 
          description: ""
          cpp_type: "stdx::variant<IndexKeyPattern, IndexName, CollScanHint>" 
          bson_serialization_type: any
          serializer: "::mongo::index_hint::append" 
          deserializer: "::mongo::index_hint::parse"
      
      structs:
        IndexHintSpec:
          description: ""
          fields: 
            ns:
              type: Namespace
              optional: true
            allowedIndexes: 
              type: array<IndexHint>  

      During compilation of this idl module, the following error appears:

      build/ninja/mongo/db/query/query_settings_gen.cpp:262:18: error: no member named 'append' in 'mpark::variant<mongo::BSONObj, std::basic_string<char>, mongo::CollScanHint>'
                  item.append(&arrayBuilder);
                  ~~~~ ^ 

      This happens because IDL generator can not serialize custom types correctly in the array.

            Assignee:
            catalin.sumanaru@mongodb.com Catalin Sumanaru
            Reporter:
            denis.grebennicov@mongodb.com Denis Grebennicov
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: