Don't just bomb out as soon as someone types an empty string.

This commit is contained in:
Dan Funk 2020-04-23 09:44:11 -04:00
parent 286af86f08
commit 65b29e1a9d
3 changed files with 13 additions and 5 deletions

View File

@ -202,8 +202,14 @@ def lookup(workflow_id, task_id, field_id, query, limit):
raise ApiError("unknown_field", "No field named %s in task %s" % (task_id, spiff_task.task_spec.name))
lookup_model = WorkflowService.get_lookup_table(spiff_task, field)
search_results = LookupDataModel.query.\
filter(LookupDataModel.lookup_file_model == lookup_model).\
filter(LookupDataModel.label.match("%s:*" % query)).limit(limit).all()
db_query = LookupDataModel.query.filter(LookupDataModel.lookup_file_model == lookup_model)
return LookupDataSchema(many=True).dump(search_results)
query = query.strip()
if(len(query) > 1):
if(' ' in query):
query = ':* ||'.join(query.split(' '))
db_query = db_query.filter(LookupDataModel.label.match("%s:*" % query)).limit(limit)
else:
db_query = db_query.filter(LookupDataModel.label.match("%s:*" % query)).limit(limit)
return LookupDataSchema(many=True).dump(db_query.all())

View File

@ -85,7 +85,7 @@ class CustomBpmnScriptEngine(BpmnScriptEngine):
return eval(expression)
except NameError as ne:
raise ApiError.from_task('invalid_expression',
'The expression you provided does not exist:' + expression,
"The expression '%s' you provided has a missing value. % s" % (expression, str(ne)),
task=task)
class MyCustomParser(BpmnDmnParser):

View File

@ -129,3 +129,5 @@ class TestWorkflowService(BaseTest):
self.assertIsNotNone(lookup_records)
self.assertEqual(2, len(lookup_records))
def test_some_queries(self):
pass