mirror of
https://github.com/jazzband/dj-database-url.git
synced 2026-03-16 22:20:24 +00:00
Merge pull request #78 from st4lk/fix-redshift-support
Support schema definition for redshift
This commit is contained in:
commit
f1b7985be1
2 changed files with 9 additions and 5 deletions
|
|
@ -114,8 +114,11 @@ def parse(url, engine=None, conn_max_age=0):
|
|||
options[key] = values[-1]
|
||||
|
||||
# Support for Postgres Schema URLs
|
||||
if 'currentSchema' in options and engine == 'django.db.backends.postgresql_psycopg2':
|
||||
options['options'] = '-c search_path={0}'.format(options['currentSchema'])
|
||||
if 'currentSchema' in options and engine in (
|
||||
'django.db.backends.postgresql_psycopg2',
|
||||
'django_redshift_backend',
|
||||
):
|
||||
options['options'] = '-c search_path={0}'.format(options.pop('currentSchema'))
|
||||
|
||||
if options:
|
||||
config['OPTIONS'] = options
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class DatabaseTestSuite(unittest.TestCase):
|
|||
assert url['PASSWORD'] == 'wegauwhgeuioweg'
|
||||
assert url['PORT'] == 5431
|
||||
assert url['OPTIONS']['options'] == '-c search_path=otherschema'
|
||||
|
||||
assert 'currentSchema' not in url['OPTIONS']
|
||||
|
||||
def test_postgres_parsing_with_special_characters(self):
|
||||
url = 'postgres://%23user:%23password@ec2-107-21-253-135.compute-1.amazonaws.com:5431/%23database'
|
||||
|
|
@ -258,7 +258,7 @@ class DatabaseTestSuite(unittest.TestCase):
|
|||
assert url['PORT'] == ''
|
||||
|
||||
def test_redshift_parsing(self):
|
||||
url = 'redshift://uf07k1i6d8ia0v:wegauwhgeuioweg@ec2-107-21-253-135.compute-1.amazonaws.com:5439/d8r82722r2kuvn'
|
||||
url = 'redshift://uf07k1i6d8ia0v:wegauwhgeuioweg@ec2-107-21-253-135.compute-1.amazonaws.com:5439/d8r82722r2kuvn?currentSchema=otherschema'
|
||||
url = dj_database_url.parse(url)
|
||||
|
||||
assert url['ENGINE'] == 'django_redshift_backend'
|
||||
|
|
@ -267,7 +267,8 @@ class DatabaseTestSuite(unittest.TestCase):
|
|||
assert url['USER'] == 'uf07k1i6d8ia0v'
|
||||
assert url['PASSWORD'] == 'wegauwhgeuioweg'
|
||||
assert url['PORT'] == 5439
|
||||
|
||||
assert url['OPTIONS']['options'] == '-c search_path=otherschema'
|
||||
assert 'currentSchema' not in url['OPTIONS']
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
Loading…
Reference in a new issue