From c9b83de6f084344a31d04a2ef4091a238106b837 Mon Sep 17 00:00:00 2001 From: Phil Varner Date: Sat, 5 Mar 2022 19:09:21 -0500 Subject: [PATCH] fix handling of empty string open-ended interval --- stac_fastapi/pgstac/stac_fastapi/pgstac/core.py | 2 +- stac_fastapi/sqlalchemy/stac_fastapi/sqlalchemy/core.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/stac_fastapi/pgstac/stac_fastapi/pgstac/core.py b/stac_fastapi/pgstac/stac_fastapi/pgstac/core.py index 2e9d4b7cb..0acfa47ba 100644 --- a/stac_fastapi/pgstac/stac_fastapi/pgstac/core.py +++ b/stac_fastapi/pgstac/stac_fastapi/pgstac/core.py @@ -186,7 +186,7 @@ async def item_collection( Called with `GET /collections/{collection_id}/items` Args: - id: id of the collection. + collection_id: id of the collection. limit: number of items to return. token: pagination token. diff --git a/stac_fastapi/sqlalchemy/stac_fastapi/sqlalchemy/core.py b/stac_fastapi/sqlalchemy/stac_fastapi/sqlalchemy/core.py index a5dc1e411..cd1ca9eea 100644 --- a/stac_fastapi/sqlalchemy/stac_fastapi/sqlalchemy/core.py +++ b/stac_fastapi/sqlalchemy/stac_fastapi/sqlalchemy/core.py @@ -349,13 +349,14 @@ def post_search( # Non-interval date ex. "2000-02-02T00:00:00.00Z" if len(dts) == 1: query = query.filter(self.item_table.datetime == dts[0]) - elif ".." not in search_request.datetime: + # is there a benefit to between instead of >= and <= ? + elif dts[0] not in ["", ".."] and dts[1] not in ["", ".."]: query = query.filter(self.item_table.datetime.between(*dts)) # All items after the start date - elif dts[0] != "..": + elif dts[0] not in ["", ".."]: query = query.filter(self.item_table.datetime >= dts[0]) # All items before the end date - elif dts[1] != "..": + elif dts[1] not in ["", ".."]: query = query.filter(self.item_table.datetime <= dts[1]) # Query fields