Skip to content

Commit

Permalink
allow non hex search
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminpkane committed Jan 21, 2025
1 parent 5505649 commit 9ddc487
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
6 changes: 5 additions & 1 deletion fiftyone/server/lightning.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,11 @@ def _add_search(query: DistinctQuery):
add = (_TWENTY_FOUR - len(search)) * "0"
if add:
search = f"{search}{add}"
value = {"$gte": ObjectId(search)}
try:
value = {"$gte": ObjectId(search)}
except:
# search is not valid
value = {"$lt": ObjectId("0" * _TWENTY_FOUR)}
else:
value = Regex(f"^{search}")
return {"$match": {query.path: value}}
Expand Down
12 changes: 12 additions & 0 deletions tests/unittests/lightning_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1204,6 +1204,18 @@ async def test_object_ids(self, dataset: fo.Dataset):
path["values"], ["000000000000000000000000"]
)

result = await _execute(
query,
dataset,
fo.ObjectIdField,
keys,
frames=False,
search="Z" * 25,
)

for path in result.data["lightning"]:
self.assertListEqual(path["values"], [])


def _add_samples(dataset: fo.Dataset, *sample_data: t.List[t.Dict]):
samples = []
Expand Down

0 comments on commit 9ddc487

Please sign in to comment.