tortoise / tortoise/tortoise-orm

Selecting schema not worked with pgbouncer

Open
#346 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
Python
Stars
5.6k
Forks
516
Avg merge
2d 21h
Merged PRs (30d)
9

Description

Describe the bug
Get error from asyncpg when set custom schema in connection credentials:
asyncpg.exceptions.ProtocolViolationError: unsupported startup parameter: search_path

To Reproduce
CREATE SCHEMA IF NOT EXISTS notpublic

await Tortoise.init(
    {
        "connections": {
            __name__: {
                "engine": "tortoise.backends.asyncpg",
                "credentials": {
                    **credentials,
                    "schema": "notpublic"
                }
            }
        },
        "apps": {"models": {"models": [__name__], "default_connection": __name__}},
    },
)

Expected behavior
Successfully init

Additional context
Support schema added in https://github.com/tortoise/tortoise-orm/pull/172 and changed in https://github.com/tortoise/tortoise-orm/pull/229

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Tortoise.init configuration with asyncpg, the custom schema credential, and PgBouncer, then trace how the schema becomes the PostgreSQL startup parameter. Confirm the fix by successfully initializing through PgBouncer and adding regression coverage for this configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, python
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.