Skip to content

Commit

Permalink
SERVER-80330 IDL generator must handle optional IDL-generated variant…
Browse files Browse the repository at this point in the history
… types
  • Loading branch information
pierlauro authored and Evergreen Agent committed Sep 13, 2023
1 parent 7cccfc0 commit 53e1c5b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions buildscripts/idl/idl/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1501,6 +1501,9 @@ def _gen_variant_deserializer_helper(self, field, field_name, bson_element):
beginning_str = '} else '
self._writer.indent()
object_value = '%s::parse(ctxt, %s)' % (variant_type.cpp_type, bson_element)
if field.optional:
cpp_type_info = cpp_types.get_cpp_type(field)
object_value = '%s(%s)' % (cpp_type_info.get_getter_setter_type(), object_value)

if field.chained_struct_field:
self._writer.write_line(
Expand Down
9 changes: 9 additions & 0 deletions src/mongo/idl/unittest.idl
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,15 @@ structs:
variant: [int, string]
optional: true

one_variant_optional_with_generated_type:
description: UnitTest for an optional variant with an IDL-generated type
strict: false
fields:
value:
type:
variant: [one_object_basic_type, string]
optional: true

one_array_variant:
description: UnitTest for an array of variant
strict: false
Expand Down

0 comments on commit 53e1c5b

Please sign in to comment.