From 8a24aab17db8ee52400f2fc0fe23c44fef1439e6 Mon Sep 17 00:00:00 2001 From: Daniel Berry Date: Wed, 14 Dec 2016 09:45:31 -0600 Subject: [PATCH] added option of postgis backend to also add path parsing. (test added also) --- dj_database_url.py | 1 + test_dj_database_url.py | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/dj_database_url.py b/dj_database_url.py index e269e9e..ada8003 100644 --- a/dj_database_url.py +++ b/dj_database_url.py @@ -115,6 +115,7 @@ def parse(url, engine=None, conn_max_age=0): # Support for Postgres Schema URLs if 'currentSchema' in options and engine in ( + 'django.contrib.gis.db.backends.postgis', 'django.db.backends.postgresql_psycopg2', 'django_redshift_backend', ): diff --git a/test_dj_database_url.py b/test_dj_database_url.py index 0882083..515eb87 100644 --- a/test_dj_database_url.py +++ b/test_dj_database_url.py @@ -68,6 +68,18 @@ class DatabaseTestSuite(unittest.TestCase): assert url['PASSWORD'] == 'wegauwhgeuioweg' assert url['PORT'] == 5431 + def test_postgis_search_path_parsing(self): + url = 'postgis://uf07k1i6d8ia0v:wegauwhgeuioweg@ec2-107-21-253-135.compute-1.amazonaws.com:5431/d8r82722r2kuvn?currentSchema=otherschema' + url = dj_database_url.parse(url) + assert url['ENGINE'] == 'django.contrib.gis.db.backends.postgis' + assert url['NAME'] == 'd8r82722r2kuvn' + assert url['HOST'] == 'ec2-107-21-253-135.compute-1.amazonaws.com' + assert url['USER'] == 'uf07k1i6d8ia0v' + assert url['PASSWORD'] == 'wegauwhgeuioweg' + assert url['PORT'] == 5431 + assert url['OPTIONS']['options'] == '-c search_path=otherschema' + assert 'currentSchema' not in url['OPTIONS'] + def test_mysql_gis_parsing(self): url = 'mysqlgis://uf07k1i6d8ia0v:wegauwhgeuioweg@ec2-107-21-253-135.compute-1.amazonaws.com:5431/d8r82722r2kuvn' url = dj_database_url.parse(url)