Skip to content

Commit

Permalink
Merge pull request #170 from stac-utils/patch/update-searches-model
Browse files Browse the repository at this point in the history
update search model for pgstac 0.9
  • Loading branch information
vincentsarago authored Aug 1, 2024
2 parents 6d84641 + 957f4bc commit 2523169
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
## Unreleased

* update models to avoid pydantic deprecation
* update `searches` model for pgstac>=9.1
* update psycopg error catching when `search` doesn't exist

## 1.3.0 (2024-05-17)

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ services:

database:
container_name: stac-db
image: ghcr.io/stac-utils/pgstac:v${PGSTAC_VERSION-0.8.5}
image: ghcr.io/stac-utils/pgstac:v${PGSTAC_VERSION-0.9.1}
environment:
- POSTGRES_USER=username
- POSTGRES_PASSWORD=password
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ test = [
"pytest-cov",
"pytest-asyncio",
"httpx",
"pypgstac>=0.8,<0.9",
"pypgstac>=0.8",
"psycopg2",
"pytest-pgsql",
]
Expand Down
4 changes: 2 additions & 2 deletions titiler/pgstac/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ class Search(BaseModel):

id: str = Field(alias="hash")
input_search: Dict[str, Any] = Field(alias="search")
sql_where: str = Field(alias="_where")
orderby: str
sql_where: Optional[str] = Field(default=None, alias="_where")
orderby: Optional[str] = None
lastused: datetime
usecount: int
metadata: Metadata
Expand Down
8 changes: 6 additions & 2 deletions titiler/pgstac/mosaic.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,13 @@ def get_assets(
)
resp = cursor.fetchone()[0]

except pgErrors.RaiseException as e:
except (pgErrors.RaiseException, pgErrors.NotNullViolation) as e:
# Catch Invalid SearchId and raise specific Error
if f"Search with Query Hash {self.input} Not Found" in str(e):
if f"Search with Query Hash {self.input} Not Found" in str(
e
) or 'null value in column "search" of relation "searches"' in str(
e
):
raise MosaicNotFoundError(
f"SearchId `{self.input}` not found"
) from e
Expand Down

0 comments on commit 2523169

Please sign in to comment.