Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set collection_id on search for pgstac get_item; update to pgstac 0.3.4 #270

Merged
merged 4 commits into from
Sep 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

* Pin FastAPI to 0.67 to avoid issues with rendering OpenAPI documentation ([#246](https://github.com/stac-utils/stac-fastapi/pull/246))
* Add `stac_version` to default search attributes ([#268](https://github.com/stac-utils/stac-fastapi/pull/268))
* pgstac backend specifies collection_id when fetching a single item ([#279](https://github.com/stac-utils/stac-fastapi/pull/270))

## [2.1.0]

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

database:
container_name: stac-db
image: ghcr.io/stac-utils/pgstac:v0.3.3
image: ghcr.io/stac-utils/pgstac:v0.3.4
environment:
- POSTGRES_USER=username
- POSTGRES_PASSWORD=password
Expand Down
2 changes: 1 addition & 1 deletion stac_fastapi/pgstac/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"pytest-asyncio",
"pre-commit",
"requests",
"pypgstac==0.3.3",
"pypgstac==0.3.4",
"httpx",
"shapely",
],
Expand Down
6 changes: 4 additions & 2 deletions stac_fastapi/pgstac/stac_fastapi/pgstac/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,12 @@ async def get_item(self, item_id: str, collection_id: str, **kwargs) -> Item:
# If collection does not exist, NotFoundError wil be raised
await self.get_collection(collection_id, **kwargs)

req = PgstacSearch(ids=[item_id], limit=1)
req = PgstacSearch(ids=[item_id], collections=[collection_id], limit=1)
item_collection = await self._search_base(req, **kwargs)
if not item_collection["features"]:
raise NotFoundError(f"Collection {collection_id} does not exist.")
raise NotFoundError(
f"Item {item_id} in Collection {collection_id} does not exist."
)

return Item(**item_collection["features"][0])

Expand Down