diff --git a/tipg/collections.py b/tipg/collections.py index d04a1da..c0c4fb4 100644 --- a/tipg/collections.py +++ b/tipg/collections.py @@ -910,8 +910,8 @@ async def get_collection_index( # noqa: C901 ) -> Catalog: """Fetch Table and Functions index.""" schemas = schemas or ["public"] - PostgresSettings() - query = """ + pg_settings = PostgresSettings() + query = f""" SELECT {pg_settings.tipg_schema}.tipg_catalog( :schemas, :tables, @@ -940,7 +940,6 @@ async def get_collection_index( # noqa: C901 spatial_extent=spatial_extent, datetime_extent=datetime_extent, ) - PostgresSettings() catalog: Dict[str, Collection] = {} table_settings = TableSettings() table_confs = table_settings.table_config @@ -951,7 +950,7 @@ async def get_collection_index( # noqa: C901 table_id = table["schema"] + "." + table["name"] confid = table["schema"] + "_" + table["name"] - if table_id == "{pg_settings.tipg_schema}.tipg_catalog": + if table_id.split(".").pop() == "tipg_catalog": continue table_conf = table_confs.get(confid, TableConfig()) diff --git a/tipg/settings.py b/tipg/settings.py index 17570da..86f607a 100644 --- a/tipg/settings.py +++ b/tipg/settings.py @@ -141,7 +141,7 @@ class PostgresSettings(BaseSettings): model_config = {"env_file": ".env", "extra": "ignore"} - tipg_schema: str = Field("pg_temp", regex=r"[a-zA-Z][a-zA-Z0-9_-]*") + tipg_schema: str = Field("pg_temp", pattern=r"[a-zA-Z][a-zA-Z0-9_-]*") # https://github.com/tiangolo/full-stack-fastapi-postgresql/blob/master/%7B%7Bcookiecutter.project_slug%7D%7D/backend/app/app/core/config.py#L42 @field_validator("database_url", mode="before")