[SERVER-81489] Allow IDL generator serialize custom types in arrays Created: 27/Sep/23  Updated: 15/Nov/23  Resolved: 07/Nov/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.2.0-rc0

Type: Bug Priority: Major - P3
Reporter: Denis Grebennicov Assignee: Catalin Sumanaru
Resolution: Fixed Votes: 0
Labels: auto-reverted
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Problem/Incident
Related
related to SERVER-81959 IDL: unambiguously distinguish betwee... Needs Scheduling
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: QE 2023-10-02, QE 2023-10-16, QE 2023-10-30, QE 2023-11-13
Participants:
Linked BF Score: 120

 Description   

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.



 Comments   
Comment by Githook User [ 06/Nov/23 ]

Author:

{'name': 'csum112', 'email': 'catalin.sumanaru@mongodb.com', 'username': ''}

Message: SERVER-81489 Allow IDL generator serialize custom types in arrays
Branch: master
https://github.com/mongodb/mongo/commit/225bbc8e78bc75d9da6f327c7e54cffb52d68393

Comment by Githook User [ 04/Nov/23 ]

Author:

{'name': 'auto-revert-processor', 'email': 'dev-prod-dag@mongodb.com', 'username': ''}

Message: Revert "SERVER-81489 Allow IDL generator serialize custom types in arrays"

This reverts commit 8c1b69f4196ffaa79749832a3bfe86493134b706.
Branch: master
https://github.com/mongodb/mongo/commit/919540a17edcf809e40cb979d65ff275bcb0d421

Comment by Githook User [ 03/Nov/23 ]

Author:

{'name': 'csum112', 'email': 'catalin.sumanaru@mongodb.com', 'username': ''}

Message: SERVER-81489 Allow IDL generator serialize custom types in arrays
Branch: master
https://github.com/mongodb/mongo/commit/8c1b69f4196ffaa79749832a3bfe86493134b706

Comment by Billy Donahue [ 06/Oct/23 ]

Work on this ticket has brought to light a syntactic problem in the way IDL specifies the names of C++ functions that it imports and uses.

It tries to determine whether a specification is referring to a member function or nonmember function.
This is not generally possible to do. An identifier can mean either thing, even if it has :: scope operators embedded, as these could still be referring to a base class member function, like:
"myns::func" could refer to an intent to specify a member function in the base class myns, invoked as: item.myns::func(). So what it does is consider something to be a nonmember function only if it has a LEADING scope operator, but this would anchor the function in global scope. It's unclear syntax.

I think we should look into the idea of extending IDL syntax so that a leading . dot will indicate member function unambiguously.
EVERYTHING else would be a nonmember function. I think we can probably sweep the codebase and make this change in a reasonable timeframe.

Generated at Thu Feb 08 06:46:39 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.