Prevent KeyError for optional data store writes (#1700)
This commit is contained in:
parent
5713cf50dc
commit
9b8ceb4af8
|
@ -69,6 +69,8 @@ class JSONDataStore(BpmnDataStoreSpecification, DataStoreCRUD): # type: ignore
|
|||
|
||||
def set(self, my_task: SpiffTask) -> None:
|
||||
"""set."""
|
||||
if self.bpmn_id not in my_task.data:
|
||||
return
|
||||
model: JSONDataStoreModel | None = None
|
||||
location = self.data_store_location_for_task(JSONDataStoreModel, my_task, self.bpmn_id)
|
||||
|
||||
|
@ -127,6 +129,8 @@ class JSONFileDataStore(BpmnDataStoreSpecification): # type: ignore
|
|||
|
||||
def set(self, my_task: SpiffTask) -> None:
|
||||
"""set."""
|
||||
if self.bpmn_id not in my_task.data:
|
||||
return
|
||||
location = self._data_store_location_for_task(my_task, self.bpmn_id)
|
||||
if location is None:
|
||||
raise DataStoreWriteError(f"Unable to write to data store '{self.bpmn_id}' using location '{location}'.")
|
||||
|
|
|
@ -114,6 +114,8 @@ class KKVDataStore(BpmnDataStoreSpecification, DataStoreCRUD): # type: ignore
|
|||
my_task.data[self.bpmn_id] = getter
|
||||
|
||||
def set(self, my_task: SpiffTask) -> None:
|
||||
if self.bpmn_id not in my_task.data:
|
||||
return
|
||||
location = self.data_store_location_for_task(KKVDataStoreModel, my_task, self.bpmn_id)
|
||||
store_model: KKVDataStoreModel | None = None
|
||||
|
||||
|
|
|
@ -43,6 +43,8 @@ class TypeaheadDataStore(BpmnDataStoreSpecification, DataStoreCRUD): # type: ig
|
|||
|
||||
def set(self, my_task: SpiffTask) -> None:
|
||||
"""set."""
|
||||
if self.bpmn_id not in my_task.data:
|
||||
return
|
||||
typeahead_data_by_category = my_task.data[self.bpmn_id]
|
||||
for category, items in typeahead_data_by_category.items():
|
||||
db.session.query(TypeaheadModel).filter_by(category=category).delete()
|
||||
|
|
Loading…
Reference in New Issue