From 2fd8c8f4168906b16da37cfd173fe283f19dccc5 Mon Sep 17 00:00:00 2001 From: vincentsarago Date: Thu, 10 Jul 2025 12:04:45 +0200 Subject: [PATCH] fix type for advanced freetext --- CHANGES.md | 4 ++++ stac_fastapi/pgstac/core.py | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index b838437..4bffb41 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -52,6 +52,10 @@ - `writer_connection_string` in `PostgresSettings` class - `testing_connection_string` in `PostgresSettings` class +### Fixed + +- Allow `q` parameter to be a `str` not a `list[str]` for Advanced Free-Text extension + ## [5.0.2] - 2025-04-07 ### Fixed diff --git a/stac_fastapi/pgstac/core.py b/stac_fastapi/pgstac/core.py index 7854ad0..aaf5db5 100644 --- a/stac_fastapi/pgstac/core.py +++ b/stac_fastapi/pgstac/core.py @@ -54,7 +54,7 @@ async def all_collections( # noqa: C901 sortby: Optional[str] = None, filter_expr: Optional[str] = None, filter_lang: Optional[str] = None, - q: Optional[List[str]] = None, + q: Optional[Union[str, List[str]]] = None, **kwargs, ) -> Collections: """Cross catalog search (GET). @@ -550,7 +550,7 @@ def _clean_search_args( # noqa: C901 sortby: Optional[str] = None, filter_query: Optional[str] = None, filter_lang: Optional[str] = None, - q: Optional[List[str]] = None, + q: Optional[Union[str, List[str]]] = None, ) -> Dict[str, Any]: """Clean up search arguments to match format expected by pgstac""" if filter_query: @@ -596,7 +596,7 @@ def _clean_search_args( # noqa: C901 base_args["fields"] = {"include": includes, "exclude": excludes} if q: - base_args["q"] = " OR ".join(q) + base_args["q"] = " OR ".join(q) if isinstance(q, list) else q # Remove None values from dict clean = {}