diff --git a/tests/backends/test_db_url.py b/tests/backends/test_db_url.py index 0f2933a55..bd1428d61 100644 --- a/tests/backends/test_db_url.py +++ b/tests/backends/test_db_url.py @@ -7,6 +7,7 @@ _postgres_scheme_engines = { "postgres": "tortoise.backends.asyncpg", + "postgresql": "tortoise.backends.asyncpg", "asyncpg": "tortoise.backends.asyncpg", "psycopg": "tortoise.backends.psycopg", } diff --git a/tortoise/backends/base/config_generator.py b/tortoise/backends/base/config_generator.py index 3ea3a7ee9..cf54cbad4 100644 --- a/tortoise/backends/base/config_generator.py +++ b/tortoise/backends/base/config_generator.py @@ -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") @@ -127,6 +128,7 @@ } # Create an alias for backwards compatibility DB_LOOKUP["postgres"] = DB_LOOKUP["asyncpg"] +DB_LOOKUP["postgresql"] = DB_LOOKUP["asyncpg"] def _quote_url_userinfo(db_url: str) -> str: @@ -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 "") )