Skip to content

Commit

Permalink
Merge pull request jazzband#86 from klashxx/oracle_fix
Browse files Browse the repository at this point in the history
Django expects Oracle Ports as strings
  • Loading branch information
kennethreitz committed Jun 16, 2017
2 parents c18e132 + e370c86 commit dd0fd73
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions dj_database_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,19 +97,22 @@ def parse(url, engine=None, conn_max_age=0):
hostname = hostname.split(":", 1)[0]
hostname = hostname.replace('%2f', '/').replace('%2F', '/')

# Lookup specified engine.
engine = SCHEMES[url.scheme] if engine is None else engine

port = (str(url.port) if url.port and engine == SCHEMES['oracle']
else url.port)

# Update with environment configuration.
config.update({
'NAME': urlparse.unquote(path or ''),
'USER': urlparse.unquote(url.username or ''),
'PASSWORD': urlparse.unquote(url.password or ''),
'HOST': hostname,
'PORT': url.port or '',
'PORT': port or '',
'CONN_MAX_AGE': conn_max_age,
})

# Lookup specified engine.
engine = SCHEMES[url.scheme] if engine is None else engine

# Pass the query string into OPTIONS.
options = {}
for key, values in query.items():
Expand Down
2 changes: 1 addition & 1 deletion test_dj_database_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def test_oracle_parsing(self):
assert url['HOST'] == 'oraclehost'
assert url['USER'] == 'scott'
assert url['PASSWORD'] == 'tiger'
assert url['PORT'] == 1521
assert url['PORT'] == '1521'

def test_oracle_gis_parsing(self):
url = 'oraclegis://scott:tiger@oraclehost:1521/hr'
Expand Down

0 comments on commit dd0fd73

Please sign in to comment.