carddef: don't match empty digests in get_data_source_items (#59542)
gitea-wip/wcs/pipeline/head Build started... Details

This commit is contained in:
Lauréline Guérin 2021-12-13 14:54:40 +01:00
parent b8d8dc66ae
commit 179e426149
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
2 changed files with 6 additions and 1 deletions

View File

@ -541,6 +541,8 @@ def test_data_source_custom_view_digest(pub):
logged_error = pub.loggederror_class.select()[1]
assert logged_error.summary == 'Digest (custom view "view") not defined'
assert logged_error.formdata_id == str(carddata2.id)
assert CardDef.get_data_source_items('carddef:foo', get_by_text='') == []
assert CardDef.get_data_source_items('carddef:foo:view', get_by_text='') == []
def test_data_source_query_escape(pub):

View File

@ -230,7 +230,10 @@ class CardDef(FormDef):
criterias.append(Equal('id_display', get_by_id))
else:
criterias.append(Equal('id', get_by_id))
if get_by_text:
if get_by_text is not None:
if not get_by_text:
# don't match empty digests
return []
criterias.append(ElementEqual('digests', digest_key, get_by_text))
items = [