From 8c91119218877808a0b84dcd8732b47862a3275f Mon Sep 17 00:00:00 2001 From: Dennis O'Brien Date: Thu, 15 Sep 2016 13:43:29 -0700 Subject: [PATCH] simplify the logic in testconn. thanks @xrmx --- caravel/views.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/caravel/views.py b/caravel/views.py index 88fdd3073886..33b64a80658e 100755 --- a/caravel/views.py +++ b/caravel/views.py @@ -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 = ( @@ -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', {})