Skip to content

Commit

Permalink
Convert tuples to lists in search_robust
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgleith committed Sep 29, 2021
1 parent 9e8527f commit 8a9f93f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion datacube/index/_products.py
Expand Up @@ -331,7 +331,12 @@ def search_robust(self, **query):
"""

def _listify(v):
return v if isinstance(v, list) else [v]
if isinstance(v, tuple):
return list(v)
elif isinstance(v, list):
return v
else:
return [v]

for type_ in self.get_all():
remaining_matchable = query.copy()
Expand Down
4 changes: 4 additions & 0 deletions integration_tests/index/test_search.py
Expand Up @@ -1195,6 +1195,10 @@ def test_query_dataset_multi_product(index: Index, ls5_dataset_w_children: Datas
datasets = dc.find_datasets(product=['ls5_nbar_scene', 'ls5_level1_scene'])
assert len(datasets) == 2

# Can we query multiple products in a tuple
datasets = dc.find_datasets(product=('ls5_nbar_scene', 'ls5_level1_scene'))
assert len(datasets) == 2


def _cli_csv_search(args, clirunner):
# Do a CSV search from the cli, returning results as a list of dictionaries
Expand Down

0 comments on commit 8a9f93f

Please sign in to comment.