Skip to content

Commit

Permalink
Check list of schemes to determine if search_path option should be …
Browse files Browse the repository at this point in the history
…added (jazzband#243)
  • Loading branch information
GertBurger authored Feb 20, 2024
1 parent 86f04ef commit bcf163e
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions dj_database_url/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@
"timescalegis": "timescale.db.backends.postgis",
}

SCHEMES_WITH_SEARCH_PATH = [
"postgres",
"postgresql",
"pgsql",
"postgis",
"redshift",
"timescale",
"timescalegis",
]

# Register database schemes in URLs.
for key in SCHEMES.keys():
urlparse.uses_netloc.append(key)
Expand Down Expand Up @@ -184,14 +194,7 @@ def parse(
options["sslmode"] = "require"

# Support for Postgres Schema URLs
if "currentSchema" in options and engine in (
"django.contrib.gis.db.backends.postgis",
"django.db.backends.postgresql_psycopg2",
"django.db.backends.postgresql",
"django_redshift_backend",
"timescale.db.backends.postgresql",
"timescale.db.backends.postgis",
):
if "currentSchema" in options and spliturl.scheme in SCHEMES_WITH_SEARCH_PATH:
options["options"] = "-c search_path={0}".format(options.pop("currentSchema"))

if options:
Expand Down

0 comments on commit bcf163e

Please sign in to comment.