summaryrefslogtreecommitdiff
path: root/buildscripts/idl
diff options
context:
space:
mode:
Diffstat (limited to 'buildscripts/idl')
-rw-r--r--buildscripts/idl/check_stable_api_commands_have_idl_definitions.py14
-rw-r--r--buildscripts/idl/gen_all_feature_flag_list.py63
-rw-r--r--buildscripts/idl/gen_all_server_params_list.py85
-rw-r--r--buildscripts/idl/idl/ast.py53
-rw-r--r--buildscripts/idl/idl/binder.py24
-rw-r--r--buildscripts/idl/idl/bson.py1
-rw-r--r--buildscripts/idl/idl/cpp_types.py52
-rw-r--r--buildscripts/idl/idl/errors.py43
-rw-r--r--buildscripts/idl/idl/generator.py123
-rw-r--r--buildscripts/idl/idl/parser.py13
-rw-r--r--buildscripts/idl/idl/struct_types.py34
-rw-r--r--buildscripts/idl/idl/syntax.py6
-rw-r--r--buildscripts/idl/idl_check_compatibility.py15
-rw-r--r--buildscripts/idl/lib.py11
-rw-r--r--buildscripts/idl/tests/test_binder.py199
-rw-r--r--buildscripts/idl/tests/test_generator.py74
16 files changed, 94 insertions, 716 deletions
diff --git a/buildscripts/idl/check_stable_api_commands_have_idl_definitions.py b/buildscripts/idl/check_stable_api_commands_have_idl_definitions.py
index 2a9d3c72420..c18077ace76 100644
--- a/buildscripts/idl/check_stable_api_commands_have_idl_definitions.py
+++ b/buildscripts/idl/check_stable_api_commands_have_idl_definitions.py
@@ -96,16 +96,16 @@ def list_commands_for_api(api_version: str, mongod_or_mongos: str, install_dir:
if mongod_or_mongos == "mongod":
logger = loggers.new_fixture_logger("MongoDFixture", 0)
logger.parent = LOGGER
- fixture: interface.Fixture = fixturelib.make_fixture(
- "MongoDFixture", logger, 0, dbpath_prefix=dbpath.name,
- mongod_executable=mongod_executable, mongod_options={"set_parameters": {}})
+ fixture: interface.Fixture = fixturelib.make_fixture("MongoDFixture", logger, 0,
+ dbpath_prefix=dbpath.name,
+ mongod_executable=mongod_executable)
else:
logger = loggers.new_fixture_logger("ShardedClusterFixture", 0)
logger.parent = LOGGER
- fixture = fixturelib.make_fixture(
- "ShardedClusterFixture", logger, 0, dbpath_prefix=dbpath.name,
- mongos_executable=mongos_executable, mongod_executable=mongod_executable,
- mongod_options={"set_parameters": {}})
+ fixture = fixturelib.make_fixture("ShardedClusterFixture", logger, 0,
+ dbpath_prefix=dbpath.name,
+ mongos_executable=mongos_executable,
+ mongod_executable=mongod_executable, mongod_options={})
fixture.setup()
fixture.await_ready()
diff --git a/buildscripts/idl/gen_all_feature_flag_list.py b/buildscripts/idl/gen_all_feature_flag_list.py
index 88fee6b367f..518583898cb 100644
--- a/buildscripts/idl/gen_all_feature_flag_list.py
+++ b/buildscripts/idl/gen_all_feature_flag_list.py
@@ -30,6 +30,7 @@ Generate a file containing a list of disabled feature flags.
Used by resmoke.py to run only feature flag tests.
"""
+import argparse
import os
import sys
@@ -42,49 +43,47 @@ sys.path.append(os.path.normpath(os.path.join(os.path.abspath(__file__), '../../
# pylint: disable=wrong-import-position
import buildscripts.idl.lib as lib
-from buildscripts.idl.idl import parser
-def gen_all_feature_flags(idl_dirs: List[str] = None):
- """Generate a list of all feature flags."""
- default_idl_dirs = ["src", "buildscripts"]
+def is_third_party_idl(idl_path: str) -> bool:
+ """Check if an IDL file is under a third party directory."""
+ third_party_idl_subpaths = [os.path.join("third_party", "mozjs"), "win32com"]
- if not idl_dirs:
- idl_dirs = default_idl_dirs
+ for file_name in third_party_idl_subpaths:
+ if file_name in idl_path:
+ return True
- all_flags = []
- for idl_dir in idl_dirs:
- for idl_path in sorted(lib.list_idls(idl_dir)):
- if lib.is_third_party_idl(idl_path):
- continue
- # Most IDL files do not contain feature flags.
- # We can discard these quickly without expensive YAML parsing.
- with open(idl_path) as idl_file:
- if 'feature_flags' not in idl_file.read():
- continue
- with open(idl_path) as idl_file:
- doc = parser.parse_file(idl_file, idl_path)
- for feature_flag in doc.spec.feature_flags:
- if feature_flag.default.literal != "true":
- all_flags.append(feature_flag.name)
-
- with open("buildscripts/resmokeconfig/fully_disabled_feature_flags.yml") as fully_disabled_ffs:
- force_disabled_flags = yaml.safe_load(fully_disabled_ffs)
+ return False
- return list(set(all_flags) - set(force_disabled_flags))
+def gen_all_feature_flags(idl_dir: str, import_dirs: List[str]):
+ """Generate a list of all feature flags."""
+ all_flags = []
+ for idl_path in sorted(lib.list_idls(idl_dir)):
+ if is_third_party_idl(idl_path):
+ continue
+ for feature_flag in lib.parse_idl(idl_path, import_dirs).spec.feature_flags:
+ if feature_flag.default.literal != "true":
+ all_flags.append(feature_flag.name)
-def gen_all_feature_flags_file(filename: str = lib.ALL_FEATURE_FLAG_FILE):
- """Output generated list of feature flags to specified file."""
- flags = gen_all_feature_flags()
- with open(filename, "w") as output_file:
- output_file.write("\n".join(flags))
- print("Generated: ", os.path.realpath(output_file.name))
+ force_disabled_flags = yaml.safe_load(
+ open("buildscripts/resmokeconfig/fully_disabled_feature_flags.yml"))
+
+ return list(set(all_flags) - set(force_disabled_flags))
def main():
"""Run the main function."""
- gen_all_feature_flags_file()
+ arg_parser = argparse.ArgumentParser(description=__doc__)
+ arg_parser.add_argument("--import-dir", dest="import_dirs", type=str, action="append",
+ help="Directory to search for IDL import files")
+
+ args = arg_parser.parse_args()
+
+ flags = gen_all_feature_flags(os.getcwd(), args.import_dirs)
+ with open(lib.ALL_FEATURE_FLAG_FILE, "w") as output_file:
+ for flag in flags:
+ output_file.write("%s\n" % flag)
if __name__ == '__main__':
diff --git a/buildscripts/idl/gen_all_server_params_list.py b/buildscripts/idl/gen_all_server_params_list.py
deleted file mode 100644
index 75dd5db45ff..00000000000
--- a/buildscripts/idl/gen_all_server_params_list.py
+++ /dev/null
@@ -1,85 +0,0 @@
-# Copyright (C) 2023-present MongoDB, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the Server Side Public License, version 1,
-# as published by MongoDB, Inc.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# Server Side Public License for more details.
-#
-# You should have received a copy of the Server Side Public License
-# along with this program. If not, see
-# <http://www.mongodb.com/licensing/server-side-public-license>.
-#
-# As a special exception, the copyright holders give permission to link the
-# code of portions of this program with the OpenSSL library under certain
-# conditions as described in each individual source file and distribute
-# linked combinations including the program with the OpenSSL library. You
-# must comply with the Server Side Public License in all respects for
-# all of the code used other than as permitted herein. If you modify file(s)
-# with this exception, you may extend this exception to your version of the
-# file(s), but you are not obligated to do so. If you do not wish to do so,
-# delete this exception statement from your version. If you delete this
-# exception statement from all source files in the program, then also delete
-# it in the license file.
-"""
-Generate a file containing a list of all available server parameters.
-
-Used by DSI to conditionally allow configuration of internalQueryStatsRateLimit parameter.
-"""
-
-import os
-import sys
-
-from typing import List
-
-# Permit imports from "buildscripts".
-sys.path.append(os.path.normpath(os.path.join(os.path.abspath(__file__), '../../..')))
-
-# pylint: disable=wrong-import-position
-from buildscripts.idl import lib
-from buildscripts.idl.idl import parser
-
-
-def gen_all_server_params(idl_dirs: List[str] = None):
- """Generate a list of all server parameters."""
- default_idl_dirs = ["src"]
-
- if not idl_dirs:
- idl_dirs = default_idl_dirs
-
- all_params = []
- for idl_dir in idl_dirs:
- for idl_path in sorted(lib.list_idls(idl_dir)):
- if lib.is_third_party_idl(idl_path):
- continue
- # Most IDL files do not contain server parameters.
- # We can discard these quickly without expensive YAML parsing.
- with open(idl_path) as idl_file:
- if 'server_parameters' not in idl_file.read():
- continue
- with open(idl_path) as idl_file:
- doc = parser.parse_file(idl_file, idl_path)
- for server_param in doc.spec.server_parameters:
- all_params.append(server_param.name)
-
- return all_params
-
-
-def gen_all_server_params_file(filename: str = "all_server_params.txt"):
- """Generate a file containing a list of all server parameters."""
- flags = gen_all_server_params()
- with open(filename, "w") as output_file:
- output_file.write("\n".join(flags))
- print("Generated: ", os.path.realpath(output_file.name))
-
-
-def main():
- """Run the main function."""
- gen_all_server_params_file()
-
-
-if __name__ == '__main__':
- main()
diff --git a/buildscripts/idl/idl/ast.py b/buildscripts/idl/idl/ast.py
index c81a8d26c0a..d86ccbbb257 100644
--- a/buildscripts/idl/idl/ast.py
+++ b/buildscripts/idl/idl/ast.py
@@ -34,7 +34,6 @@ This is a lossy translation from the IDL Syntax tree as the IDL AST only contain
the enums and structs that need code generated for them, and just enough information to do that.
"""
from abc import ABCMeta, abstractmethod
-import enum
from typing import Any, Dict, List, Optional
from . import common, errors
@@ -114,9 +113,6 @@ class Type(common.SourceLocation):
# A variant can have at most one alternative type which is a struct. Otherwise, if we saw
# a sub-object while parsing BSON, we wouldn't know which struct to interpret it as.
self.variant_struct_type = None # type: Type
- # Marks whether this type is a query shape component.
- # Can only be true if is_struct is true.
- self.is_query_shape_component = False # type: bool
super(Type, self).__init__(file_name, line, column)
@@ -148,9 +144,6 @@ class Struct(common.SourceLocation):
self.allow_global_collection_name = False # type: bool
self.non_const_getter = False # type: bool
self.cpp_validator_func = None # type: str
-
- # Determines whether or not this IDL struct can be a component of a query shape. See WRITING-13831.
- self.query_shape_component = False # type: bool
super(Struct, self).__init__(file_name, line, column)
@@ -191,34 +184,6 @@ class Validator(common.SourceLocation):
super(Validator, self).__init__(file_name, line, column)
-@enum.unique
-class QueryShapeFieldType(enum.Enum):
- """Enum describing how to treat a field in the context of query shape computation."""
-
- # Abstract literal from shape.
- LITERAL = enum.auto()
- # Leave value as-is in shape.
- PARAMETER = enum.auto()
- # Anonymize string value.
- ANONYMIZE = enum.auto()
- # IDL type uses custom serializer -- defer to that serializer.
- CUSTOM = enum.auto()
-
- @classmethod
- def bind(cls, string_value):
- # type: (Optional[str]) -> Optional[QueryShapeFieldType]
- """Parses the string to the enum type."""
- if string_value is None:
- return None
- bindings = {
- "literal": cls.LITERAL,
- "parameter": cls.PARAMETER,
- "anonymize": cls.ANONYMIZE,
- "custom": cls.CUSTOM,
- }
- return bindings.get(string_value, None)
-
-
class Field(common.SourceLocation):
"""
An instance of a field in a struct.
@@ -258,26 +223,8 @@ class Field(common.SourceLocation):
# Validation rules.
self.validator = None # type: Optional[Validator]
- # Determines whether or not this field represents a literal value that should be abstracted when serializing a query shape.
- # See WRITING-13831 for details on query shape.
- self.query_shape = None # type: Optional[QueryShapeFieldType]
-
super(Field, self).__init__(file_name, line, column)
- @property
- def should_serialize_with_options(self):
- # type: () -> bool
- """Returns true if the IDL compiler should add a call to serialization options for this field."""
- return self.query_shape is not None and self.query_shape in [
- QueryShapeFieldType.LITERAL, QueryShapeFieldType.ANONYMIZE
- ]
-
- @property
- def should_shapify(self):
- # type: () -> bool
- """Returns true if the IDL compiler should treat this field as a query literal."""
- return self.query_shape is not None and self.query_shape != QueryShapeFieldType.PARAMETER
-
class Privilege(common.SourceLocation):
"""IDL privilege information."""
diff --git a/buildscripts/idl/idl/binder.py b/buildscripts/idl/idl/binder.py
index 853088cede6..1511b6c1b07 100644
--- a/buildscripts/idl/idl/binder.py
+++ b/buildscripts/idl/idl/binder.py
@@ -271,7 +271,6 @@ def _bind_struct_common(ctxt, parsed_spec, struct, ast_struct):
ast_struct.qualified_cpp_name = _get_struct_qualified_cpp_name(struct)
ast_struct.allow_global_collection_name = struct.allow_global_collection_name
ast_struct.non_const_getter = struct.non_const_getter
- ast_struct.query_shape_component = struct.query_shape_component
# Validate naming restrictions
if ast_struct.name.startswith("array<"):
@@ -308,20 +307,6 @@ def _bind_struct_common(ctxt, parsed_spec, struct, ast_struct):
if not _is_duplicate_field(ctxt, ast_struct.name, ast_struct.fields, ast_field):
ast_struct.fields.append(ast_field)
- # Verify that each field on the struct defines a query shape type on the field if and only if
- # query_shape_component is defined on the struct.
- if not field.hidden and struct.query_shape_component and ast_field.query_shape is None:
- ctxt.add_must_declare_shape_type(ast_field, ast_struct.name, ast_field.name)
-
- if not struct.query_shape_component and ast_field.query_shape is not None:
- ctxt.add_must_be_query_shape_component(ast_field, ast_struct.name, ast_field.name)
-
- if ast_field.query_shape == ast.QueryShapeFieldType.ANONYMIZE and not (
- ast_field.type.cpp_type in ["std::string", "std::vector<std::string>"]
- or 'string' in ast_field.type.bson_serialization_type):
- ctxt.add_query_shape_anonymize_must_be_string(ast_field, ast_field.name,
- ast_field.type.cpp_type)
-
# Fill out the field comparison_order property as needed
if ast_struct.generate_comparison_operators and ast_struct.fields:
# If the user did not specify an ordering of fields, then number all fields in
@@ -435,7 +420,6 @@ def _bind_struct_type(struct):
ast_type.name = struct.name
ast_type.cpp_type = _get_struct_qualified_cpp_name(struct)
ast_type.bson_serialization_type = ["object"]
- ast_type.is_query_shape_component = struct.query_shape_component
return ast_type
@@ -985,7 +969,6 @@ def _bind_type(idltype):
ast_type.bindata_subtype = idltype.bindata_subtype
ast_type.serializer = _normalize_method_name(idltype.cpp_type, idltype.serializer)
ast_type.deserializer = _normalize_method_name(idltype.cpp_type, idltype.deserializer)
- ast_type.is_query_shape_component = True
return ast_type
@@ -1010,11 +993,6 @@ def _bind_field(ctxt, parsed_spec, field):
ast_field.unstable = field.unstable
ast_field.always_serialize = field.always_serialize
- if field.query_shape is not None:
- ast_field.query_shape = ast.QueryShapeFieldType.bind(field.query_shape)
- if ast_field.query_shape is None:
- ctxt.add_invalid_query_shape_value(ast_field, field.query_shape)
-
ast_field.cpp_name = field.name
if field.cpp_name:
ast_field.cpp_name = field.cpp_name
@@ -1095,8 +1073,6 @@ def _bind_field(ctxt, parsed_spec, field):
if ast_field.validator is None:
return None
- if ast_field.should_shapify and not ast_field.type.is_query_shape_component:
- ctxt.add_must_be_query_shape_component(ast_field, ast_field.type.name, ast_field.name)
return ast_field
diff --git a/buildscripts/idl/idl/bson.py b/buildscripts/idl/idl/bson.py
index c7ead4cd66e..8216b5d743d 100644
--- a/buildscripts/idl/idl/bson.py
+++ b/buildscripts/idl/idl/bson.py
@@ -73,7 +73,6 @@ _BINDATA_SUBTYPE = {
"uuid": {'scalar': True, 'bindata_enum': 'newUUID'},
"md5": {'scalar': True, 'bindata_enum': 'MD5Type'},
"encrypt": {'scalar': True, 'bindata_enum': 'Encrypt'},
- "sensitive": {'scalar': True, 'bindata_enum': 'Sensitive'},
}
diff --git a/buildscripts/idl/idl/cpp_types.py b/buildscripts/idl/idl/cpp_types.py
index ba3a0b6bce6..d8e37dfcc56 100644
--- a/buildscripts/idl/idl/cpp_types.py
+++ b/buildscripts/idl/idl/cpp_types.py
@@ -577,14 +577,14 @@ class BsonCppTypeBase(object, metaclass=ABCMeta):
pass
@abstractmethod
- def gen_serializer_expression(self, indented_writer, expression, should_shapify=False):
- # type: (writer.IndentedTextWriter, str, bool) -> str
+ def gen_serializer_expression(self, indented_writer, expression):
+ # type: (writer.IndentedTextWriter, str) -> str
"""Generate code with the text writer and return an expression to serialize the type."""
pass
-def _call_method_or_global_function(expression, method_name, should_shapify=False):
- # type: (str, str, bool) -> str
+def _call_method_or_global_function(expression, method_name):
+ # type: (str, str) -> str
"""
Given a fully-qualified method name, call it correctly.
@@ -592,19 +592,13 @@ def _call_method_or_global_function(expression, method_name, should_shapify=Fals
not treated as a global C++ function though. This notion of functions is designed to support
enum deserializers/serializers which are not methods.
"""
- shape_options = ''
- if should_shapify:
- shape_options = 'options'
-
short_method_name = writer.get_method_name(method_name)
if writer.is_function(method_name):
- return common.template_args('${method_name}(${expression}${shape_options})',
- expression=expression, method_name=method_name,
- shape_options=shape_options)
+ return common.template_args('${method_name}(${expression})', expression=expression,
+ method_name=method_name)
- return common.template_args('${expression}.${method_name}(${shape_options})',
- expression=expression, method_name=short_method_name,
- shape_options=shape_options)
+ return common.template_args('${expression}.${method_name}()', expression=expression,
+ method_name=short_method_name)
class _CommonBsonCppTypeBase(BsonCppTypeBase):
@@ -625,10 +619,9 @@ class _CommonBsonCppTypeBase(BsonCppTypeBase):
# type: () -> bool
return self._ast_type.serializer is not None
- def gen_serializer_expression(self, indented_writer, expression, should_shapify=False):
- # type: (writer.IndentedTextWriter, str, bool) -> str
- return _call_method_or_global_function(expression, self._ast_type.serializer,
- should_shapify)
+ def gen_serializer_expression(self, indented_writer, expression):
+ # type: (writer.IndentedTextWriter, str) -> str
+ return _call_method_or_global_function(expression, self._ast_type.serializer)
class _ObjectBsonCppTypeBase(BsonCppTypeBase):
@@ -650,19 +643,12 @@ class _ObjectBsonCppTypeBase(BsonCppTypeBase):
# type: () -> bool
return self._ast_type.serializer is not None
- def gen_serializer_expression(self, indented_writer, expression, should_shapify=False):
- # type: (writer.IndentedTextWriter, str, bool) -> str
+ def gen_serializer_expression(self, indented_writer, expression):
+ # type: (writer.IndentedTextWriter, str) -> str
method_name = writer.get_method_name(self._ast_type.serializer)
- function_arguments = []
- # Provide options if custom shapification required.
- if should_shapify:
- function_arguments.append('options')
-
indented_writer.write_line(
- common.template_args(
- 'const BSONObj localObject = ${expression}.${method_name}(${function_arguments});',
- expression=expression, method_name=method_name,
- function_arguments=', '.join(function_arguments)))
+ common.template_args('const BSONObj localObject = ${expression}.${method_name}();',
+ expression=expression, method_name=method_name))
return "localObject"
@@ -685,8 +671,8 @@ class _ArrayBsonCppTypeBase(BsonCppTypeBase):
# type: () -> bool
return self._ast_type.serializer is not None
- def gen_serializer_expression(self, indented_writer, expression, should_shapify=False):
- # type: (writer.IndentedTextWriter, str, bool) -> str
+ def gen_serializer_expression(self, indented_writer, expression):
+ # type: (writer.IndentedTextWriter, str) -> str
method_name = writer.get_method_name(self._ast_type.serializer)
indented_writer.write_line(
common.template_args('BSONArray localArray(${expression}.${method_name}());',
@@ -709,8 +695,8 @@ class _BinDataBsonCppTypeBase(BsonCppTypeBase):
# type: () -> bool
return True
- def gen_serializer_expression(self, indented_writer, expression, should_shapify=False):
- # type: (writer.IndentedTextWriter, str, bool) -> str
+ def gen_serializer_expression(self, indented_writer, expression):
+ # type: (writer.IndentedTextWriter, str) -> str
if self._ast_type.serializer:
method_name = writer.get_method_name(self._ast_type.serializer)
indented_writer.write_line(
diff --git a/buildscripts/idl/idl/errors.py b/buildscripts/idl/idl/errors.py
index 0f030cf6573..47cd8ecf3f4 100644
--- a/buildscripts/idl/idl/errors.py
+++ b/buildscripts/idl/idl/errors.py
@@ -128,12 +128,6 @@ ERROR_ID_DUPLICATE_ACCESS_CHECK = "ID0087"
ERROR_ID_DUPLICATE_PRIVILEGE = "ID0088"
ERROR_ID_EMPTY_ACCESS_CHECK = "ID0089"
ERROR_ID_MISSING_ACCESS_CHECK = "ID0090"
-ERROR_ID_FIELD_MUST_DECLARE_SHAPE_LITERAL = "ID0094"
-ERROR_ID_CANNOT_DECLARE_SHAPE_LITERAL = "ID0095"
-ERROR_ID_INVALID_TYPE_FOR_SHAPIFY = "ID0096"
-ERROR_ID_QUERY_SHAPE_PROPERTIES_MUTUALLY_EXCLUSIVE = "ID0097"
-ERROR_ID_QUERY_SHAPE_PROPERTY_CANNOT_BE_FALSE = "ID0098"
-ERROR_ID_QUERY_SHAPE_INVALID_VALUE = "ID0102"
class IDLError(Exception):
@@ -375,15 +369,6 @@ class ParserContext(object):
return True
return False
- def get_required_bool(self, node):
- # type: (Union[yaml.nodes.MappingNode, yaml.nodes.ScalarNode, yaml.nodes.SequenceNode]) -> bool
- """Get a YAML bool and enforce it is specified."""
- boolean_value = yaml.safe_load(node.value)
- if not isinstance(boolean_value, bool):
- self._add_node_error(node, ERROR_ID_IS_NODE_VALID_BOOL,
- "Illegal bool value, expected either 'true' or 'false'.")
- return boolean_value
-
def get_list(self, node):
# type: (Union[yaml.nodes.MappingNode, yaml.nodes.ScalarNode, yaml.nodes.SequenceNode]) -> List[str]
"""Get a YAML scalar or sequence node as a list of strings."""
@@ -982,34 +967,6 @@ class ParserContext(object):
self._add_error(location, ERROR_ID_MISSING_ACCESS_CHECK,
'Command "%s" has api_version != "" but is missing access_check.' % (name))
- def add_must_declare_shape_type(self, location, struct_name, field_name):
- # type: (common.SourceLocation, str, str) -> None
- """Add an error about a field not specifying either query_shape_literal or query_shape_anonymize if the struct is query_shape_component."""
- self._add_error(
- location, ERROR_ID_FIELD_MUST_DECLARE_SHAPE_LITERAL,
- f"Field '{field_name}' must specify either 'query_shape_literal' or 'query_shape_anonymize' since struct '{struct_name}' is a query shape component."
- )
-
- def add_must_be_query_shape_component(self, location, struct_name, field_name):
- # type: (common.SourceLocation, str, str) -> None
- """Add an error about specifying 'query_shape_literal' without being a shape component."""
- self._add_error(
- location, ERROR_ID_CANNOT_DECLARE_SHAPE_LITERAL,
- f"Field '{field_name}' cannot specify 'query_shape_literal' property since struct '{struct_name}' is not a query shape component."
- )
-
- def add_query_shape_anonymize_must_be_string(self, location, field_name, field_type):
- """Add an error about field paths needing to be strings."""
- self._add_error(
- location, ERROR_ID_INVALID_TYPE_FOR_SHAPIFY,
- f"In order for {field_name} to be marked as a query shape fieldpath, it must have a string type, not {field_type}."
- )
-
- def add_invalid_query_shape_value(self, location, query_shape_value):
- """Assert that the query shape value is one of the accepted values."""
- self._add_error(location, ERROR_ID_QUERY_SHAPE_INVALID_VALUE,
- f"'{query_shape_value}' is not a valid value for 'query_shape'.")
-
def _assert_unique_error_messages():
# type: () -> None
diff --git a/buildscripts/idl/idl/generator.py b/buildscripts/idl/idl/generator.py
index d3c62204623..d8b38d51a0c 100644
--- a/buildscripts/idl/idl/generator.py
+++ b/buildscripts/idl/idl/generator.py
@@ -1032,10 +1032,6 @@ class _CppHeaderFileWriter(_CppFileWriterBase):
if any(command.api_version for command in spec.commands):
header_list.append('mongo/db/commands.h')
- # Include serialization options only if there is a struct which is part of a query shape.
- if any(struct.query_shape_component for struct in spec.structs):
- header_list.append('mongo/db/query/query_shape/serialization_options.h')
-
header_list.sort()
for include in header_list:
@@ -1879,23 +1875,6 @@ class _CppSourceFileWriter(_CppFileWriterBase):
self._gen_command_deserializer(struct, "request.body")
- def _gen_single_field_serialize_expression(self, template_params, field, bson_cpp_type):
- """Helper to append the code to serialize a single field, as part of a custom type."""
- expression = bson_cpp_type.gen_serializer_expression(
- self._writer, _access_member(field),
- field.query_shape == ast.QueryShapeFieldType.CUSTOM)
- template_params['expression'] = expression
- if not field.should_serialize_with_options:
- self._writer.write_template('builder->append(${field_name}, ${expression});')
- elif field.query_shape == ast.QueryShapeFieldType.LITERAL:
- self._writer.write_template(
- 'options.serializeLiteral(${expression}).serializeForIDL(${field_name}, builder);')
- else:
- assert field.query_shape == ast.QueryShapeFieldType.ANONYMIZE
- self._writer.write_template(
- 'builder->append(${field_name}, options.serializeFieldPathFromString(${expression}));'
- )
-
def _gen_serializer_method_custom(self, field):
# type: (ast.Field) -> None
"""Generate the serialize method definition for a custom type."""
@@ -1916,14 +1895,14 @@ class _CppSourceFileWriter(_CppFileWriterBase):
self._writer.write_template(
'BSONArrayBuilder arrayBuilder(builder->subarrayStart(${field_name}));')
with self._block('for (const auto& item : ${access_member}) {', '}'):
- expression = bson_cpp_type.gen_serializer_expression(
- self._writer, 'item',
- field.query_shape == ast.QueryShapeFieldType.CUSTOM)
+ expression = bson_cpp_type.gen_serializer_expression(self._writer, 'item')
template_params['expression'] = expression
self._writer.write_template('arrayBuilder.append(${expression});')
else:
- self._gen_single_field_serialize_expression(template_params, field,
- bson_cpp_type)
+ expression = bson_cpp_type.gen_serializer_expression(
+ self._writer, _access_member(field))
+ template_params['expression'] = expression
+ self._writer.write_template('builder->append(${field_name}, ${expression});')
elif field.type.bson_serialization_type[0] == 'any':
# Any types are special
@@ -1939,17 +1918,14 @@ class _CppSourceFileWriter(_CppFileWriterBase):
# Call a method like class::method(BSONArrayBuilder*)
self._writer.write_template('item.${method_name}(&arrayBuilder);')
else:
- template_params[
- 'query_shape_options'] = ', options' if field.query_shape == ast.QueryShapeFieldType.CUSTOM else ''
if writer.is_function(field.type.serializer):
+ # Call a method like method(value, StringData, BSONObjBuilder*)
self._writer.write_template(
- '${method_name}(${access_member}, ${field_name}, builder${query_shape_options});'
- )
+ '${method_name}(${access_member}, ${field_name}, builder);')
else:
- # Call a method like class::method(StringData, BSONObjBuilder*, SerializationOptions)
+ # Call a method like class::method(StringData, BSONObjBuilder*)
self._writer.write_template(
- '${access_member}.${method_name}(${field_name}, builder${query_shape_options});'
- )
+ '${access_member}.${method_name}(${field_name}, builder);')
else:
method_name = writer.get_method_name(field.type.serializer)
@@ -1984,29 +1960,18 @@ class _CppSourceFileWriter(_CppFileWriterBase):
if field.chained:
# Just directly call the serializer for chained structs without opening up a nested
# document.
- if not field.should_serialize_with_options:
- self._writer.write_template('${access_member}.serialize(builder);')
- else:
- self._writer.write_template('${access_member}.serialize(builder, options);')
-
+ self._writer.write_template('${access_member}.serialize(builder);')
elif field.type.is_array:
self._writer.write_template(
'BSONArrayBuilder arrayBuilder(builder->subarrayStart(${field_name}));')
with self._block('for (const auto& item : ${access_member}) {', '}'):
self._writer.write_line(
'BSONObjBuilder subObjBuilder(arrayBuilder.subobjStart());')
- if not field.should_serialize_with_options:
- self._writer.write_line('item.serialize(&subObjBuilder);')
- else:
- self._writer.write_line('item.serialize(&subObjBuilder, options);')
+ self._writer.write_line('item.serialize(&subObjBuilder);')
else:
self._writer.write_template(
'BSONObjBuilder subObjBuilder(builder->subobjStart(${field_name}));')
- if not field.should_serialize_with_options:
- self._writer.write_template('${access_member}.serialize(&subObjBuilder);')
- else:
- self._writer.write_template(
- '${access_member}.serialize(&subObjBuilder, options);')
+ self._writer.write_template('${access_member}.serialize(&subObjBuilder);')
def _gen_serializer_method_variant(self, field):
# type: (ast.Field) -> None
@@ -2025,44 +1990,18 @@ class _CppSourceFileWriter(_CppFileWriterBase):
template_params[
'cpp_type'] = 'std::vector<' + variant_type.cpp_type + '>' if variant_type.is_array else variant_type.cpp_type
- template_params['param_opt'] = "builder"
- if field.should_serialize_with_options:
- template_params['param_opt'] += ', options'
- with self._block('[${param_opt}](const ${cpp_type}& value) {', '},'):
+ with self._block('[builder](const ${cpp_type}& value) {', '},'):
bson_cpp_type = cpp_types.get_bson_cpp_type(variant_type)
if bson_cpp_type and bson_cpp_type.has_serializer():
assert not field.type.is_array
expression = bson_cpp_type.gen_serializer_expression(
- self._writer, 'value',
- field.query_shape == ast.QueryShapeFieldType.CUSTOM)
+ self._writer, 'value')
template_params['expression'] = expression
- if not field.should_serialize_with_options:
- self._writer.write_template(
- 'builder->append(${field_name}, ${expression});')
- elif field.query_shape == ast.QueryShapeFieldType.LITERAL:
- self._writer.write_template(
- 'options.serializeLiteral(${expression}).serializeForIDL(${field_name}, builder);'
- )
- elif field.query_shape == ast.QueryShapeFieldType.ANONYMIZE:
- self._writer.write_template(
- 'builder->append(${field_name}, options.serializeFieldPathFromString(${expression}));'
- )
- else:
- assert False
+ self._writer.write_template(
+ 'builder->append(${field_name}, ${expression});')
else:
- if not field.should_serialize_with_options:
- self._writer.write_template(
- 'idl::idlSerialize(builder, ${field_name}, value);')
- elif field.query_shape == ast.QueryShapeFieldType.LITERAL:
- self._writer.write_template(
- 'options.serializeLiteral(value).serializeForIDL(${field_name}, builder);'
- )
- elif field.query_shape == ast.QueryShapeFieldType.ANONYMIZE:
- self._writer.write_template(
- 'idl::idlSerialize(builder, ${field_name}, options.serializeFieldPathFromString(value));'
- )
- else:
- assert False
+ self._writer.write_template(
+ 'idl::idlSerialize(builder, ${field_name}, value);')
def _gen_serializer_method_common(self, field):
# type: (ast.Field) -> None
@@ -2091,27 +2030,11 @@ class _CppSourceFileWriter(_CppFileWriterBase):
elif field.type.is_variant:
self._gen_serializer_method_variant(field)
else:
- # Generate default serialization
- # Note: BSONObjBuilder::append, which all three branches use, has overrides for std::vector also
- if not field.should_serialize_with_options:
- self._writer.write_line(
- 'builder->append(%s, %s);' % (_get_field_constant_name(field),
- _access_member(field)))
- elif field.query_shape == ast.QueryShapeFieldType.LITERAL:
- # serializeLiteral expects an ImplicitValue, which can't be constructed with an int64_t
- expression_cast = ""
- if field.type.cpp_type == "std::int64_t":
- expression_cast = "(long long)"
- self._writer.write_line(
- 'options.serializeLiteral(%s%s).serializeForIDL(%s, builder);'
- % (expression_cast, _access_member(field),
- _get_field_constant_name(field)))
- elif field.query_shape == ast.QueryShapeFieldType.ANONYMIZE:
- self._writer.write_line(
- 'builder->append(%s, options.serializeFieldPathFromString(%s));' %
- (_get_field_constant_name(field), _access_member(field)))
- else:
- assert False
+ # Generate default serialization using BSONObjBuilder::append
+ # Note: BSONObjBuilder::append has overrides for std::vector also
+ self._writer.write_line(
+ 'builder->append(%s, %s);' % (_get_field_constant_name(field),
+ _access_member(field)))
else:
self._gen_serializer_method_struct(field)
diff --git a/buildscripts/idl/idl/parser.py b/buildscripts/idl/idl/parser.py
index 2582a6626b9..2d9925db500 100644
--- a/buildscripts/idl/idl/parser.py
+++ b/buildscripts/idl/idl/parser.py
@@ -134,8 +134,6 @@ def _generic_parser(
if ctxt.is_mapping_node(second_node, first_name):
syntax_node.__dict__[first_name] = rule_desc.mapping_parser_func(
ctxt, second_node)
- elif rule_desc.node_type == "required_bool_scalar":
- syntax_node.__dict__[first_name] = ctxt.get_required_bool(second_node)
else:
raise errors.IDLError(
"Unknown node_type '%s' for parser rule" % (rule_desc.node_type))
@@ -151,7 +149,7 @@ def _generic_parser(
# A bool is never "None" like other types, it simply defaults to "false".
# It means "if bool is None" will always return false and there is no support for required
- # 'bool' at this time. Use the node type 'required_bool_scalar' if this behavior is not desired.
+ # 'bool' at this time.
if not rule_desc.node_type == 'bool_scalar':
if syntax_node.__dict__[name] is None:
ctxt.add_missing_required_field_error(node, syntax_node_name, name)
@@ -376,8 +374,6 @@ def _parse_field(ctxt, name, node):
_RuleDesc("bool_scalar"),
"always_serialize":
_RuleDesc("bool_scalar"),
- "query_shape":
- _RuleDesc('scalar'),
})
return field
@@ -531,7 +527,6 @@ def _parse_struct(ctxt, spec, name, node):
"generate_comparison_operators": _RuleDesc("bool_scalar"),
"non_const_getter": _RuleDesc('bool_scalar'),
"cpp_validator_func": _RuleDesc('scalar'),
- "query_shape_component": _RuleDesc('bool_scalar'),
})
# PyLint has difficulty with some iterables: https://github.com/PyCQA/pylint/issues/3105
@@ -1006,7 +1001,7 @@ def _propagate_globals(spec):
idltype.cpp_type = _prefix_with_namespace(cpp_namespace, idltype.cpp_type)
-def parse_file(stream, error_file_name):
+def _parse(stream, error_file_name):
# type: (Any, str) -> syntax.IDLParsedSpec
"""
Parse a YAML document into an idl.syntax tree.
@@ -1110,7 +1105,7 @@ def parse(stream, input_file_name, resolver):
"""
# pylint: disable=too-many-locals
- root_doc = parse_file(stream, input_file_name)
+ root_doc = _parse(stream, input_file_name)
if root_doc.errors:
return root_doc
@@ -1147,7 +1142,7 @@ def parse(stream, input_file_name, resolver):
# Parse imported file
with resolver.open(resolved_file_name) as file_stream:
- parsed_doc = parse_file(file_stream, resolved_file_name)
+ parsed_doc = _parse(file_stream, resolved_file_name)
# Check for errors
if parsed_doc.errors:
diff --git a/buildscripts/idl/idl/struct_types.py b/buildscripts/idl/idl/struct_types.py
index 7a8d0867a6d..b3b0df60532 100644
--- a/buildscripts/idl/idl/struct_types.py
+++ b/buildscripts/idl/idl/struct_types.py
@@ -67,27 +67,15 @@ class ArgumentInfo(object):
def __init__(self, arg):
# type: (str) -> None
"""Create a instance of the ArgumentInfo class by parsing the argument string."""
- self.defaults = None
- equal_tokens = arg.split('=')
- if len(equal_tokens) > 1:
- self.defaults = equal_tokens[-1].strip()
-
- space_tokens = equal_tokens[0].strip().split(' ')
- self.type = ' '.join(space_tokens[0:-1])
- self.name = space_tokens[-1]
+ parts = arg.split(' ')
+ self.type = ' '.join(parts[0:-1])
+ self.name = parts[-1]
def __str__(self):
# type: () -> str
"""Return a formatted argument string."""
return "%s %s" % (self.type, self.name) # type: ignore
- def get_string(self, get_defaults):
- # type: (bool) -> str
- """Return a formatted argument string."""
- if self.defaults and get_defaults:
- return "%s %s = %s" % (self.type, self.name, self.defaults) # type: ignore
- return "%s %s" % (self.type, self.name) # type: ignore
-
class MethodInfo(object):
"""Class that encapslates information about a method and how to declare, define, and call it."""
@@ -127,8 +115,7 @@ class MethodInfo(object):
return common.template_args(
"${pre_modifiers}${return_type}${method_name}(${args})${post_modifiers};",
pre_modifiers=pre_modifiers, return_type=return_type_str, method_name=self.method_name,
- args=', '.join(
- [arg.get_string(True) for arg in self.args]), post_modifiers=post_modifiers)
+ args=', '.join([str(arg) for arg in self.args]), post_modifiers=post_modifiers)
def get_definition(self):
# type: () -> str
@@ -147,7 +134,7 @@ class MethodInfo(object):
"${pre_modifiers}${return_type}${class_name}::${method_name}(${args})${post_modifiers}",
pre_modifiers=pre_modifiers, return_type=return_type_str, class_name=self.class_name,
method_name=self.method_name, args=', '.join(
- [arg.get_string(False) for arg in self.args]), post_modifiers=post_modifiers)
+ [str(arg) for arg in self.args]), post_modifiers=post_modifiers)
def get_call(self, obj):
# type: (Optional[str]) -> str
@@ -281,19 +268,14 @@ class _StructTypeInfo(StructTypeInfoBase):
def get_serializer_method(self):
# type: () -> MethodInfo
- args = ['BSONObjBuilder* builder']
- if self._struct.query_shape_component:
- args.append("const SerializationOptions& options = {}")
return MethodInfo(
- common.title_case(self._struct.cpp_name), 'serialize', args, 'void', const=True)
+ common.title_case(self._struct.cpp_name), 'serialize', ['BSONObjBuilder* builder'],
+ 'void', const=True)
def get_to_bson_method(self):
# type: () -> MethodInfo
- args = []
- if self._struct.query_shape_component:
- args.append("const SerializationOptions& options = {}")
return MethodInfo(
- common.title_case(self._struct.cpp_name), 'toBSON', args, 'BSONObj', const=True)
+ common.title_case(self._struct.cpp_name), 'toBSON', [], 'BSONObj', const=True)
def get_op_msg_request_serializer_method(self):
# type: () -> Optional[MethodInfo]
diff --git a/buildscripts/idl/idl/syntax.py b/buildscripts/idl/idl/syntax.py
index 27edf420c43..0cfcf88e73d 100644
--- a/buildscripts/idl/idl/syntax.py
+++ b/buildscripts/idl/idl/syntax.py
@@ -471,10 +471,6 @@ class Field(common.SourceLocation):
self.serialize_op_msg_request_only = False # type: bool
self.constructed = False # type: bool
- self.query_shape = None # type: Optional[str]
-
- self.hidden = False # type: bool
-
super(Field, self).__init__(file_name, line, column)
@@ -545,8 +541,6 @@ class Struct(common.SourceLocation):
# Internal property: cpp_namespace from globals section
self.cpp_namespace = None # type: str
- self.query_shape_component = False # type: bool
-
super(Struct, self).__init__(file_name, line, column)
diff --git a/buildscripts/idl/idl_check_compatibility.py b/buildscripts/idl/idl_check_compatibility.py
index 7b3ad4bee94..1a30f29428a 100644
--- a/buildscripts/idl/idl_check_compatibility.py
+++ b/buildscripts/idl/idl_check_compatibility.py
@@ -184,12 +184,6 @@ IGNORE_UNSTABLE_LIST: List[str] = [
# The 'runtimeConstants' field is a legacy field for internal use only and is not documented to
# users.
'delete-param-runtimeConstants',
- # The 'bypassEmptyTsReplacement' field is used by mongorestore and mongosync and is not
- # documented to users.
- 'insert-param-bypassEmptyTsReplacement',
- 'update-param-bypassEmptyTsReplacement',
- 'delete-param-bypassEmptyTsReplacement',
- 'findAndModify-param-bypassEmptyTsReplacement',
]
SKIPPED_FILES = [
@@ -830,13 +824,8 @@ def check_param_or_type_validator(ctxt: IDLCompatibilityContext, old_field: synt
ctxt.add_command_or_param_type_validators_not_equal_error(
cmd_name, new_field.name, new_idl_file_path, type_name, is_command_parameter)
else:
- new_field_name: str = cmd_name + "-param-" + new_field.name
- # In SERVER-77382 we fixed the error handling of creating time-series collections by
- # adding a new validator to two 'stable' fields, but it didn't break any stable API
- # guarantees.
- if new_field_name not in ["create-param-timeField", "create-param-metaField"]:
- ctxt.add_command_or_param_type_contains_validator_error(
- cmd_name, new_field.name, new_idl_file_path, type_name, is_command_parameter)
+ ctxt.add_command_or_param_type_contains_validator_error(
+ cmd_name, new_field.name, new_idl_file_path, type_name, is_command_parameter)
def get_all_struct_fields(struct: syntax.Struct, idl_file: syntax.IDLParsedSpec,
diff --git a/buildscripts/idl/lib.py b/buildscripts/idl/lib.py
index 5484f98e9d3..c4ae1c08fea 100644
--- a/buildscripts/idl/lib.py
+++ b/buildscripts/idl/lib.py
@@ -56,14 +56,3 @@ def parse_idl(idl_path: str, import_directories: List[str]) -> syntax.IDLParsedS
raise ValueError(f"Cannot parse {idl_path}")
return parsed_doc
-
-
-def is_third_party_idl(idl_path: str) -> bool:
- """Check if an IDL file is under a third party directory."""
- third_party_idl_subpaths = [os.path.join("third_party", "mozjs"), "win32com"]
-
- for file_name in third_party_idl_subpaths:
- if file_name in idl_path:
- return True
-
- return False
diff --git a/buildscripts/idl/tests/test_binder.py b/buildscripts/idl/tests/test_binder.py
index 32f42772e8d..b52c755e34b 100644
--- a/buildscripts/idl/tests/test_binder.py
+++ b/buildscripts/idl/tests/test_binder.py
@@ -71,39 +71,6 @@ class TestBinder(testcase.IDLTestcase):
# pylint: disable=too-many-public-methods
- # Create a text wrap for common types.
- common_types = textwrap.dedent("""
- types:
- object:
- description: foo
- cpp_type: foo
- bson_serialization_type: object
- serializer: foo
- deserializer: foo
-
- bool:
- description: foo
- cpp_type: foo
- bson_serialization_type: any
- serializer: foo
- deserializer: foo
-
- string:
- description: foo
- cpp_type: foo
- bson_serialization_type: string
- serializer: foo
- deserializer: foo
-
- any_type:
- description: foo
- cpp_type: foo
- bson_serialization_type: any
- serializer: foo
- deserializer: foo
-
- """)
-
def test_empty(self):
# type: () -> None
"""Test an empty document works."""
@@ -2775,172 +2742,6 @@ class TestBinder(testcase.IDLTestcase):
reply_type: reply
"""), idl.errors.ERROR_ID_MISSING_ACCESS_CHECK)
- def test_query_shape_component_validation(self):
- """Tests for the query shape component fields."""
- self.assert_bind(self.common_types + textwrap.dedent("""
- structs:
- struct1:
- query_shape_component: true
- strict: true
- description: ""
- fields:
- field1:
- query_shape: literal
- type: string
- field2:
- type: bool
- query_shape: parameter
- """))
-
- self.assert_bind_fail(
- self.common_types + textwrap.dedent("""
- structs:
- struct1:
- query_shape_component: true
- strict: true
- description: ""
- fields:
- field1:
- type: string
- field2:
- type: bool
- query_shape: parameter
- """), idl.errors.ERROR_ID_FIELD_MUST_DECLARE_SHAPE_LITERAL)
-
- self.assert_bind_fail(
- self.common_types + textwrap.dedent("""
- structs:
- struct1:
- strict: true
- description: ""
- fields:
- field1:
- type: string
- field2:
- type: bool
- query_shape: parameter
- """), idl.errors.ERROR_ID_CANNOT_DECLARE_SHAPE_LITERAL)
-
- # Validating query_shape_anonymize relies on std::string
- basic_types = textwrap.dedent("""
- types:
- string:
- bson_serialization_type: string
- description: "A BSON UTF-8 string"
- cpp_type: "std::string"
- deserializer: "mongo::BSONElement::str"
- bool:
- bson_serialization_type: bool
- description: "A BSON bool"
- cpp_type: "bool"
- deserializer: "mongo::BSONElement::boolean"
- """)
- self.assert_bind(basic_types + textwrap.dedent("""
- structs:
- struct1:
- query_shape_component: true
- strict: true
- description: ""
- fields:
- field1:
- query_shape: anonymize
- type: string
- field2:
- query_shape: parameter
- type: bool
- """))
-
- self.assert_bind(basic_types + textwrap.dedent("""
- structs:
- struct1:
- query_shape_component: true
- strict: true
- description: ""
- fields:
- field1:
- query_shape: anonymize
- type: array<string>
- field2:
- query_shape: parameter
- type: bool
- """))
-
- self.assert_bind_fail(
- basic_types + textwrap.dedent("""
- structs:
- struct1:
- strict: true
- description: ""
- fields:
- field1:
- query_shape: blah
- type: string
- """), idl.errors.ERROR_ID_QUERY_SHAPE_INVALID_VALUE)
-
- self.assert_bind_fail(
- basic_types + textwrap.dedent("""
- structs:
- struct1:
- query_shape_component: true
- strict: true
- description: ""
- fields:
- field1:
- query_shape: anonymize
- type: bool
- field2:
- query_shape: parameter
- type: bool
- """), idl.errors.ERROR_ID_INVALID_TYPE_FOR_SHAPIFY)
-
- self.assert_bind_fail(
- basic_types + textwrap.dedent("""
- structs:
- struct1:
- query_shape_component: true
- strict: true
- description: ""
- fields:
- field1:
- query_shape: anonymize
- type: array<bool>
- field2:
- query_shape: parameter
- type: bool
- """), idl.errors.ERROR_ID_INVALID_TYPE_FOR_SHAPIFY)
-
- self.assert_bind_fail(
- basic_types + textwrap.dedent("""
- structs:
- StructZero:
- strict: true
- description: ""
- fields:
- field1:
- query_shape: literal
- type: string
- """), idl.errors.ERROR_ID_CANNOT_DECLARE_SHAPE_LITERAL)
-
- self.assert_bind_fail(
- basic_types + textwrap.dedent("""
- structs:
- StructZero:
- strict: true
- description: ""
- fields:
- field1:
- type: string
- struct1:
- query_shape_component: true
- strict: true
- description: ""
- fields:
- field2:
- type: StructZero
- description: ""
- query_shape: literal
- """), idl.errors.ERROR_ID_CANNOT_DECLARE_SHAPE_LITERAL)
-
if __name__ == '__main__':
diff --git a/buildscripts/idl/tests/test_generator.py b/buildscripts/idl/tests/test_generator.py
index 97020f1eb8e..ee8a251aa53 100644
--- a/buildscripts/idl/tests/test_generator.py
+++ b/buildscripts/idl/tests/test_generator.py
@@ -38,7 +38,6 @@ $ coverage run run_tests.py && coverage html
import os
import unittest
-from textwrap import dedent
# import package so that it works regardless of whether we run as a module or file
if __package__ is None:
@@ -133,79 +132,6 @@ class TestGenerator(testcase.IDLTestcase):
self.assertTrue(found, "Bad Header: " + header)
- def test_object_with_custom_serializer_and_query_shape(self) -> None:
- """Serialization with custom query_shape."""
- _, source = self.assert_generate("""
- types:
- object_type_with_custom_serializer:
- bson_serialization_type: object
- description: ObjWithCustomSerializer
- cpp_type: ObjWithCustomSerializer
- serializer: ObjWithCustomSerializer::toBSON
- deserializer: ObjWithCustomSerializer::parse
-
- structs:
- QueryShapeSpec:
- description: QueryShape
- query_shape_component: true
- fields:
- internalObject:
- type: object_type_with_custom_serializer
- optional: false
- description: internalObject
- query_shape: custom
- """)
-
- expected = dedent("""
- void QueryShapeSpec::serialize(BSONObjBuilder* builder, const SerializationOptions& options) const {
- invariant(_hasInternalObject);
-
- {
- const BSONObj localObject = _internalObject.toBSON(options);
- builder->append(kInternalObjectFieldName, localObject);
- }
-
- }""")
- self.assertIn(expected, source)
-
- def test_array_with_custom_serializer_and_query_shape(self) -> None:
- """Serialization with custom query_shape used, array use case."""
- _, source = self.assert_generate("""
- types:
- object_type_with_custom_serializer:
- bson_serialization_type: object
- description: ObjWithCustomSerializer
- cpp_type: ObjWithCustomSerializer
- serializer: ObjWithCustomSerializer::toBSON
- deserializer: ObjWithCustomSerializer::parse
-
- structs:
- QueryShapeSpec:
- description: QueryShape
- query_shape_component: true
- fields:
- internalObjectArray:
- type: array<object_type_with_custom_serializer>
- optional: false
- description: internalObjectArray
- query_shape: custom
- """)
-
- expected = dedent("""
- void QueryShapeSpec::serialize(BSONObjBuilder* builder, const SerializationOptions& options) const {
- invariant(_hasInternalObjectArray);
-
- {
- BSONArrayBuilder arrayBuilder(builder->subarrayStart(kInternalObjectArrayFieldName));
- for (const auto& item : _internalObjectArray) {
- const BSONObj localObject = item.toBSON(options);
- arrayBuilder.append(localObject);
- }
- }
-
- }""")
- self.assertIn(expected, source)
-
if __name__ == '__main__':