The DatabaseMapping.get_*_item() methods generally return an empty dict if the item does not exist. However, when at least the following is in effect:
There is a parameter definition x that is using a value list
There is a parameter defined for x in an alternative, say A
Trying to db_map.get_parameter_value_item() for an alternative that is notA gives a Traceback:
Traceback (most recent call last):
File "tests\test_DatabaseMapping.py", line 828, in test_nonexistent_parameter_value_with_list_value_does_not_traceback
value = db_map.get_parameter_value_item(
File "spinedb_api\db_mapping.py", line 426, in get_item
item = mapped_table.find_item(kwargs)
File "spinedb_api\db_mapping_base.py", line 437, in find_item
return self._find_item_by_unique_key(item, skip_keys=skip_keys, fetch=fetch)
File "spinedb_api\db_mapping_base.py", line 456, in _find_item_by_unique_key
error = mapped_item.polish()
File "spinedb_api\mapped_items.py", line 437, in polish
type_ = super().__getitem__(self._type_key)
File "spinedb_api\mapped_items.py", line 380, in __getitem__
return super().__getitem__(key)
File "spinedb_api\db_mapping_base.py", line 1200, in __getitem__
return super().__getitem__(key)
KeyError: 'type'
The
DatabaseMapping.get_*_item()
methods generally return an emptydict
if the item does not exist. However, when at least the following is in effect:x
that is using a value listx
in an alternative, sayA
Trying to
db_map.get_parameter_value_item()
for an alternative that is notA
gives a Traceback:It should rather return an empty
dict
.