[SERVER-74481] Unable to use BSON serializer/deserializer in a nested namespace Created: 01/Mar/23 Updated: 11/Apr/23 |
|
| Status: | Open |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Antonio Fuschetto | Assignee: | Backlog - Service Architecture |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Assigned Teams: |
Service Arch
|
| Participants: |
| 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:
The compiler generates the following code:
The problem is that the function serializeStatusToBSON is defined in the namespace mongo::util, not in mongo. |
| Comments |
| Comment by Antonio Fuschetto [ 28/Mar/23 ] | |||||
|
Hi billy.donahue@mongodb.com and elizabeth.roytburd@mongodb.com, sorry for my late reply. I'm not asking to create a mongo::util namespace. Let me describe to problem with a more tangible example:
In this example, the serializer and deserializer functions have been defined in the mongo namespace instead of mongo::sharding_ddl_util to bypass the problem. Can you suggest an alternative solution? At present I added the prefix sharding_ddl_util to the function names as a reminder that these should be defined in another namespace:
Let me know if you need any additional information. | |||||
| Comment by Billy Donahue [ 16/Mar/23 ] | |||||
|
Hi Antonio. A couple things from the ServiceArch triage of this ticket here. We don't want to create a "mongo::util" namespace. A central serializeStatusToBSON function would be a design of its own and not done as part of another ticket as a side-effect. I'm not clear about what your "only solution" above is doing or why it would be unacceptable. The stripping of the "mongo::util::" prefix from "serializeStatusToBSON" in the generated code doesn't look right to me. If I understand correctly, this is the main idea of the bug report here? | |||||
| Comment by Antonio Fuschetto [ 01/Mar/23 ] | |||||
|
I tried to use different alternatives for the type definition, e.g., the one below, but the problem is still the same. The only solution is to define the IDL in the same nested namespace, which is not acceptable in many cases.
|