diff --git a/spinedb_api/mapped_items.py b/spinedb_api/mapped_items.py index 7348dcae..5d20cb60 100644 --- a/spinedb_api/mapped_items.py +++ b/spinedb_api/mapped_items.py @@ -822,7 +822,7 @@ def __init__(self, db_map, **kwargs): super().__init__(db_map, **kwargs) if "parameter_type_list" in kwargs: self._init_type_list = kwargs["parameter_type_list"] - if len(set(self._init_type_list)) != len(self._init_type_list): + if self._init_type_list is not None and len(set(self._init_type_list)) != len(self._init_type_list): raise SpineDBAPIError("entries in parameter_type_list must be unique") else: self._init_type_list = None diff --git a/tests/test_parameter_definitions.py b/tests/test_parameter_definitions.py new file mode 100644 index 00000000..bc5c363b --- /dev/null +++ b/tests/test_parameter_definitions.py @@ -0,0 +1,17 @@ +###################################################################################################################### +# Copyright (C) 2017-2022 Spine project consortium +# Copyright Spine Database API contributors +# This file is part of Spine Database API. +# Spine Database API is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser +# General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your +# option) any later version. 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 GNU Lesser General +# Public License for more details. You should have received a copy of the GNU Lesser General Public License along with +# this program. If not, see . +###################################################################################################################### +def test_add_or_update_when_setting_parameter_type_list_to_none(db_map): + db_map.add_entity_class(name="Gadget") + definition = db_map.add_or_update_parameter_definition( + entity_class_name="Gadget", name="X", parameter_type_list=None + ) + assert definition["parameter_type_list"] == ()