Skip to content

Commit

Permalink
update TinyDB q= support for multiple terms (geopython#765)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkralidis committed Aug 26, 2021
1 parent 1ff9dfa commit 70edc3c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pygeoapi/provider/tinydb_.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ def query(self, startindex=0, limit=10, resulttype='results',
QUERY.append("(Q.properties['{}']=='{}')".format(*prop))

if q is not None:
QUERY.append("(Q.properties['_metadata-anytext'].search('{}'))".format(q)) # noqa
for t in q.split():
QUERY.append("(Q.properties['_metadata-anytext'].search('{}'))".format(t)) # noqa

QUERY_STRING = '&'.join(QUERY)
LOGGER.debug('QUERY_STRING: {}'.format(QUERY_STRING))
Expand Down
5 changes: 5 additions & 0 deletions tests/test_tinydb_catalogue_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ def test_query(config):
assert results['numberMatched'] == 6
assert results['numberReturned'] == 6

results = p.query(q='crops barley')
assert len(results['features']) == 2
assert results['numberMatched'] == 2
assert results['numberReturned'] == 2

results = p.query(limit=1)
assert len(results['features']) == 1
assert results['features'][0]['id'] == 'e5a71860-827c-453f-990e-0e0ba0ee67bb' # noqa
Expand Down

0 comments on commit 70edc3c

Please sign in to comment.