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

Adds the ability to use a schema other than pg_temp for installing catalog functions. #191

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

bitner
Copy link
Contributor

@bitner bitner commented Sep 16, 2024

Adds the tipg_schema setting to PostgresSettings defaulting to "pg_temp" to allow installing tipg catalog functions into a permanent schema (NOTE: this schema must already exist, and the logged in user must have full permissions to the schema!).

Basically, this is just doing a replace of "pg_temp" in the dbcatalog.sql with whatever is set in the tipg_schema setting.

@@ -141,6 +141,8 @@ class PostgresSettings(BaseSettings):

model_config = {"env_file": ".env", "extra": "ignore"}

tipg_schema: str = Field("pg_temp", pattern=r"[a-zA-Z][a-zA-Z0-9_-]*")
Copy link
Member

Choose a reason for hiding this comment

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

  • can you move this up, before the model_config
  • what do you think about TIPG_SCHEMA_NAME ?

@@ -61,10 +62,14 @@ async def __call__(self, conn: asyncpg.Connection):

# Register custom SQL functions/table/views in pg_temp
for sqlfile in self.user_sql_files:
await conn.execute(sqlfile.read_text())
await conn.execute(
sqlfile.read_text().replace("pg_temp", settings.tipg_schema)
Copy link
Member

Choose a reason for hiding this comment

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

I'm trying to think about the use case for the custom function to have access the the pg_temp schema?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants