Skip to content

Commit f89b277

Browse files
committed
Merge branch 'stac-fastapi-6' into more-stac-extensions
2 parents 38fd3f4 + 42bb5d1 commit f89b277

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
33
# Ruff version.
4-
rev: v0.12.1
4+
rev: v0.12.2
55
hooks:
66
# Run the linter.
77
- id: ruff-check

CHANGES.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@
2121
_**NOTE**_: <br>
2222
The `CollectionSearchPostExtension` is purposely omitted as it would conflict with the `Transaction` extension
2323
that both uses the same `POST /collections` enpodint for search and collection creation respectively.
24-
2524

2625
# Fixed
2726

28-
- n/a
27+
- Fix breaking PG connection setting when using ``stac-fastapi>=6``.
2928

3029
[1.1.0](https://github.com/crim-ca/stac-app/tree/1.1.0)
3130
------------------------------------------------------------------------------------------------------------------

src/stac_app.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@
1010
from buildpg import render
1111
from fastapi import APIRouter, HTTPException, Request, Response
1212
from fastapi.responses import ORJSONResponse
13+
from packaging.version import Version
1314
from stac_fastapi.api.app import StacApi
1415
from stac_fastapi.api.models import (
1516
ItemCollectionUri,
1617
create_get_request_model,
1718
create_post_request_model,
1819
)
20+
from stac_fastapi.api.version import __version__ as stac_fastapi_version
1921
from stac_fastapi.extensions.core import (
2022
CollectionSearchFilterExtension,
2123
FieldsExtension,
@@ -167,9 +169,15 @@ async def _load_script(script_basename: str, conn: asyncpg.Connection) -> None:
167169
async def startup_event() -> None:
168170
"""Connect to database on startup and load custom functions."""
169171
max_retries = 60
172+
173+
# forward-compatibility setting
174+
connect_to_db_kwargs = {}
175+
if Version(stac_fastapi_version) >= Version("6.0"):
176+
connect_to_db_kwargs["add_write_connection_pool"] = True
177+
170178
for retry in range(max_retries):
171179
try:
172-
await connect_to_db(app)
180+
await connect_to_db(app, **connect_to_db_kwargs)
173181
break
174182
except Exception as err:
175183
logger.warning(

0 commit comments

Comments
 (0)