Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/backends/test_db_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

_postgres_scheme_engines = {
"postgres": "tortoise.backends.asyncpg",
"postgresql": "tortoise.backends.asyncpg",
"asyncpg": "tortoise.backends.asyncpg",
"psycopg": "tortoise.backends.psycopg",
}
Expand Down
4 changes: 3 additions & 1 deletion tortoise/backends/base/config_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from tortoise.exceptions import ConfigurationError

urlparse.uses_netloc.append("postgres")
urlparse.uses_netloc.append("postgresql")
urlparse.uses_netloc.append("asyncpg")
urlparse.uses_netloc.append("psycopg")
urlparse.uses_netloc.append("sqlite")
Expand Down Expand Up @@ -127,6 +128,7 @@
}
# Create an alias for backwards compatibility
DB_LOOKUP["postgres"] = DB_LOOKUP["asyncpg"]
DB_LOOKUP["postgresql"] = DB_LOOKUP["asyncpg"]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please add a comment line before it:

# Create an alias for pydantic compatibility

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@r266-tech Now that "postgresql" is not for backwards compatibility, it would be better to add a comment explaining why this line is added.



def _quote_url_userinfo(db_url: str) -> str:
Expand Down Expand Up @@ -211,7 +213,7 @@ def expand_db_url(db_url: str, testing: bool = False) -> dict:
# asyncpg accepts None for password, but aiomysql not
params[vmap["password"]] = (
None
if (not url.password and db_backend in {"postgres", "asyncpg", "psycopg"})
if (not url.password and db_backend in {"postgres", "postgresql", "asyncpg", "psycopg"})
else urlparse.unquote(url.password or "")
)

Expand Down
Loading