Skip to content

Commit 04c7c7f

Browse files
authored
fix STAC API POST limit parameter handling (#1110)
1 parent 4d15c0e commit 04c7c7f

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

pycsw/ogc/api/records.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,8 @@ def items(self, headers_, json_post_data, args, collection='metadata:main'):
739739
return self.get_exception(400, headers_, 'InvalidParameterValue', msg)
740740
if limit > self.limit:
741741
limit = self.limit
742+
elif limit is not None:
743+
pass
742744
else:
743745
limit = self.limit
744746

@@ -747,6 +749,9 @@ def items(self, headers_, json_post_data, args, collection='metadata:main'):
747749
LOGGER.debug(f'Query: {query}')
748750
LOGGER.debug('Querying repository')
749751
count = query.count()
752+
LOGGER.debug(f'count: {count}')
753+
LOGGER.debug(f'limit: {limit}')
754+
LOGGER.debug(f'offset: {offset}')
750755
records = query.limit(limit).offset(offset).all()
751756

752757
returned = len(records)

tests/functionaltests/suites/stac_api/test_stac_api_functional.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,11 @@ def test_items(config):
233233
for feature in content['features']:
234234
assert feature['collection'] == 'S2MSI1C'
235235

236+
# test limit
237+
content = json.loads(api.items({}, {'limit': 1}, {})[2])
238+
239+
assert content['numberReturned'] == 1
240+
assert content['numberMatched'] == 30
236241

237242
def test_item(config):
238243
api = STACAPI(config)

0 commit comments

Comments
 (0)