Skip to content

Commit 977154f

Browse files
Merge pull request #225 from developmentseed/patch/remove-tipg-schema-alias-settings
remove alias for tipg-schema in DatabaseSettings
2 parents 871ee56 + ddb4d1b commit 977154f

File tree

3 files changed

+43
-3
lines changed

3 files changed

+43
-3
lines changed

CHANGES.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ Note: Minor version `0.X.0` update might break the API, It's recommended to pin
88

99
## [unreleased]
1010

11+
## [1.1.1] - 2025-06-13
12+
13+
* remove `tipg_schema` alias in `DatabaseSettings` to support env variable settings
14+
1115
## [1.1.0] - 2025-05-06
1216

1317
* update geojson-pydantic requirement to `>=1.0,<3.0`
@@ -394,7 +398,8 @@ Note: Minor version `0.X.0` update might break the API, It's recommended to pin
394398

395399
- Initial release
396400

397-
[unreleased]: https://github.com/developmentseed/tipg/compare/1.1.0...HEAD
401+
[unreleased]: https://github.com/developmentseed/tipg/compare/1.1.1...HEAD
402+
[1.1.1]: https://github.com/developmentseed/tipg/compare/1.1.1...1.1.1
398403
[1.1.0]: https://github.com/developmentseed/tipg/compare/1.0.1...1.1.0
399404
[1.0.1]: https://github.com/developmentseed/tipg/compare/1.0.0...1.0.1
400405
[1.0.0]: https://github.com/developmentseed/tipg/compare/0.10.0...1.0.0

tests/test_settings.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import pytest
44
from pydantic import ValidationError
55

6-
from tipg.settings import PostgresSettings
6+
from tipg.settings import DatabaseSettings, PostgresSettings
77

88

99
def test_pg_settings(monkeypatch):
@@ -48,3 +48,31 @@ def test_pg_settings(monkeypatch):
4848
)
4949
assert str(settings.database_url) == "postgresql://user:secret@0.0.0.0:8888/db"
5050
assert not settings.postgres_port
51+
52+
53+
def test_db_settings(monkeypatch):
54+
"""test DatabaseSettings class."""
55+
monkeypatch.delenv("TIPG_DB_SCHEMAS", raising=False)
56+
monkeypatch.delenv("TIPG_DB_APPLICATION_SCHEMA", raising=False)
57+
58+
settings = DatabaseSettings(_env_file=None)
59+
assert settings.schemas == ["public"]
60+
assert settings.tipg_schema == "pg_temp"
61+
62+
settings = DatabaseSettings(
63+
schemas=["private"],
64+
application_schema="pg_tipg_temp",
65+
_env_file=None,
66+
)
67+
assert settings.schemas == ["private"]
68+
assert settings.tipg_schema == "pg_tipg_temp"
69+
70+
71+
def test_db_settings_env(monkeypatch):
72+
"""test DatabaseSettings class with env variable."""
73+
monkeypatch.setenv("TIPG_DB_SCHEMAS", '["private"]')
74+
monkeypatch.setenv("TIPG_DB_APPLICATION_SCHEMA", "pg_tipg_temp")
75+
76+
settings = DatabaseSettings(_env_file=None)
77+
assert settings.schemas == ["private"]
78+
assert settings.tipg_schema == "pg_tipg_temp"

tipg/settings.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ class DatabaseSettings(BaseSettings):
164164
"""TiPg Database settings."""
165165

166166
schemas: List[str] = ["public"]
167-
tipg_schema: str = Field("pg_temp", alias="application_schema")
167+
application_schema: str = "pg_temp"
168168
tables: Optional[List[str]] = None
169169
exclude_tables: Optional[List[str]] = None
170170
exclude_table_schemas: Optional[List[str]] = None
@@ -178,6 +178,13 @@ class DatabaseSettings(BaseSettings):
178178

179179
model_config = {"env_prefix": "TIPG_DB_", "env_file": ".env", "extra": "ignore"}
180180

181+
@property
182+
def tipg_schema(self):
183+
"""Compat: use application_schema for input and tipg_schema for attribute.
184+
see https://github.com/developmentseed/tipg/issues/224
185+
"""
186+
return self.application_schema
187+
181188

182189
class CustomSQLSettings(BaseSettings):
183190
"""TiPg Custom SQL settings."""

0 commit comments

Comments
 (0)