Skip to content

Commit

Permalink
MNT: support searching UUIDs with 'like' operator
Browse files Browse the repository at this point in the history
  • Loading branch information
shilorigins committed Sep 19, 2024
1 parent 5d5f830 commit 4891cce
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions superscore/backends/filestore.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,8 @@ def compare(op: str, data: AnyEpicsType, target: SearchTermValue) -> bool:
elif op == "in":
return data in target
elif op == "like":
if isinstance(data, UUID):
data = str(data)
return re.search(target, data)
else:
raise ValueError(f"SearchTerm does not support operator \"{op}\"")
Expand Down
5 changes: 5 additions & 0 deletions superscore/tests/test_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ def test_fuzzy_search(backends: _Backend):
)
assert len(results) == 2

results = list(backends.search(
SearchTerm('uuid', 'like', '17cc6ebf'))
)
assert len(results) == 1


@pytest.mark.parametrize('backends', [0], indirect=True)
def test_tag_search(backends: _Backend):
Expand Down

0 comments on commit 4891cce

Please sign in to comment.