Skip to content

update for stac-fastapi 6.0 #257

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

Merged
merged 1 commit into from
Jun 22, 2025
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
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"attrs",
"orjson",
"pydantic",
"stac-fastapi.api>=5.2,<6.0",
"stac-fastapi.extensions>=5.2,<6.0",
"stac-fastapi.types>=5.2,<6.0",
"stac-fastapi.api>=6.0,<7.0",
"stac-fastapi.extensions>=6.0,<7.0",
"stac-fastapi.types>=6.0,<7.0",
"asyncpg",
"buildpg",
"brotli_asgi",
Expand Down
28 changes: 26 additions & 2 deletions stac_fastapi/pgstac/transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,23 @@

import logging
import re
from typing import Optional, Union
from typing import List, Optional, Union

import attr
from buildpg import render
from fastapi import HTTPException, Request
from stac_fastapi.extensions.core.transaction import AsyncBaseTransactionsClient
from stac_fastapi.extensions.core.transaction.request import (
PartialCollection,
PartialItem,
PatchOperation,
)
from stac_fastapi.extensions.third_party.bulk_transactions import (
AsyncBaseBulkTransactionsClient,
BulkTransactionMethod,
Items,
)
from stac_fastapi.types import stac as stac_types
from stac_fastapi.types.core import AsyncBaseTransactionsClient
from stac_pydantic import Collection, Item, ItemCollection
from starlette.responses import JSONResponse, Response

Expand Down Expand Up @@ -203,6 +208,25 @@ async def delete_collection(

return JSONResponse({"deleted collection": collection_id})

async def patch_item(
self,
collection_id: str,
item_id: str,
patch: Union[PartialItem, List[PatchOperation]],
**kwargs,
) -> Optional[Union[stac_types.Item, Response]]:
"""Patch Item."""
raise NotImplementedError

async def patch_collection(
self,
collection_id: str,
patch: Union[PartialCollection, List[PatchOperation]],
**kwargs,
) -> Optional[Union[stac_types.Collection, Response]]:
"""Patch Collection."""
raise NotImplementedError
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To do in other PR



@attr.s
class BulkTransactionsClient(AsyncBaseBulkTransactionsClient, ClientValidateMixIn):
Expand Down
2 changes: 1 addition & 1 deletion stac_fastapi/pgstac/types/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class PgstacSearch(BaseSearchPostRequest):
@classmethod
def validate_query_uses_cql(cls, v: str, info: ValidationInfo):
"""Use of Query Extension is not allowed with cql2."""
if info.data.get("query", None) is not None and v != "cql-json":
if info.data.get("query", None) is not None:
raise ValueError(
"Query extension is not available when using pgstac with cql2"
)
Expand Down
86 changes: 0 additions & 86 deletions tests/resources/test_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -1356,52 +1356,6 @@ async def test_preserves_extra_link(
assert extra_link[0]["href"] == expected_href


async def test_item_search_post_filter_extension_cql_explicitlang(
app_client, load_test_data, load_test_collection
):
"""Test POST search with JSONB query (cql json filter extension)"""
test_item = load_test_data("test_item.json")
resp = await app_client.post(
f"/collections/{test_item['collection']}/items", json=test_item
)
assert resp.status_code == 201

# EPSG is a JSONB key
params = {
"collections": [test_item["collection"]],
"filter-lang": "cql-json",
"filter": {
"gt": [
{"property": "proj:epsg"},
test_item["properties"]["proj:epsg"] + 1,
]
},
}
resp = await app_client.post("/search", json=params)
resp_json = resp.json()

assert resp.status_code == 200
assert len(resp_json.get("features")) == 0

params = {
"collections": [test_item["collection"]],
"filter-lang": "cql-json",
"filter": {
"eq": [
{"property": "proj:epsg"},
test_item["properties"]["proj:epsg"],
]
},
}
resp = await app_client.post("/search", json=params)
resp_json = resp.json()
assert len(resp.json()["features"]) == 1
assert (
resp_json["features"][0]["properties"]["proj:epsg"]
== test_item["properties"]["proj:epsg"]
)


async def test_item_search_post_filter_extension_cql2_2(
app_client, load_test_data, load_test_collection
):
Expand Down Expand Up @@ -1622,26 +1576,6 @@ async def test_get_filter_extension(app_client, load_test_data, load_test_collec
assert len(fc["features"]) == 1
assert fc["features"][0]["id"] == search_id

# CQL-JSON
resp = await app_client.get(
"/search",
params={
"filter-lang": "cql-json",
"filter": json.dumps(
{
"eq": [
{"property": "id"},
search_id,
],
},
),
},
)
assert resp.status_code == 200
fc = resp.json()
assert len(fc["features"]) == 1
assert fc["features"][0]["id"] == search_id

# CQL2-TEXT
resp = await app_client.get(
"/search",
Expand Down Expand Up @@ -1669,26 +1603,6 @@ async def test_get_filter_extension(app_client, load_test_data, load_test_collec
assert len(fc["features"]) == 1
assert fc["features"][0]["id"] == search_id

# CQL-JSON
resp = await app_client.get(
f"/collections/{collection_id}/items",
params={
"filter-lang": "cql-json",
"filter": json.dumps(
{
"eq": [
{"property": "id"},
search_id,
],
},
),
},
)
assert resp.status_code == 200
fc = resp.json()
assert len(fc["features"]) == 1
assert fc["features"][0]["id"] == search_id

# CQL2-TEXT
resp = await app_client.get(
f"/collections/{collection_id}/items",
Expand Down
Loading