Skip to content

Commit

Permalink
simplify the logic in testconn. thanks @xrmx
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisobrien committed Sep 15, 2016
1 parent 78588d5 commit 8c91119
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions caravel/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,7 @@ def add_slices(self, dashboard_id):
def testconn(self):
"""Tests a sqla connection"""
try:
request_uri = request.json.get('uri')
uri = request.json.get('uri')
database_name = request.json.get('database_name')
if database_name:
database = (
Expand All @@ -1250,16 +1250,10 @@ def testconn(self):
.filter_by(database_name=database_name)
.first()
)
if request_uri != database.safe_sqlalchemy_uri():
# the user altered the SQLAlchemy URI field
# so use that for testing the connection
uri = request_uri
else:
if uri == database.safe_sqlalchemy_uri():
# the password-masked uri was passed
# use the URI associated with this database
uri = database.sqlalchemy_uri_decrypted
else:
# database_name was not passed as an argument
uri = request_uri
connect_args = (
request.json
.get('extras', {})
Expand Down

0 comments on commit 8c91119

Please sign in to comment.