@@ -327,42 +327,50 @@ def setConnection(connectionName, callback=None):
327327 if connectionName not in ST .connectionDict :
328328 return
329329
330+ settings = settingsStore .all ()
330331 config = ST .connectionDict .get (connectionName )
331332
332333 promptKeys = [key for key , value in config .items () if value is None ]
333334 promptDict = {}
335+ logger .info ('[setConnection] prompt keys {}' .format (promptKeys ))
334336
335- def createConnection (promptedKeys ):
336- nonlocal config
337- nonlocal callback
338- settings = settingsStore .all ()
337+ def mergeConfig (config , promptedKeys = None ):
339338 merged = config .copy ()
340- merged .update (promptedKeys )
339+ if promptedKeys :
340+ merged .update (promptedKeys )
341+ return merged
342+
343+ def createConnection (connectionName , config , settings , callback = None ):
341344 # if DB cli binary could not be found in path a FileNotFoundError is thrown
342345 try :
343- ST .conn = Connection (connectionName , merged , settings = settings )
346+ ST .conn = Connection (connectionName , config , settings = settings )
344347 except FileNotFoundError as e :
345348 # use only first line of the Exception in status message
346349 Window ().status_message (__package__ + ": " + str (e ).splitlines ()[0 ])
347350 raise e
348351 ST .loadConnectionData (callback )
349352
353+ if not promptKeys :
354+ createConnection (connectionName , config , settings , callback )
355+ return
356+
350357
351358 def setMissingKey (key , value ):
352359 nonlocal promptDict
353- nonlocal promptKeys
354360 if value is None :
355361 return
356362 promptDict [key ] = value
357363 if promptKeys :
358364 promptNext ()
359365 else :
360- createConnection (promptDict );
366+ merged = mergeConfig (config , promptDict )
367+ createConnection (connectionName , merged , settings , callback )
361368
362369 def promptNext ():
363370 nonlocal promptKeys
364371 if not promptKeys :
365- return
372+ merged = mergeConfig (config , promptDict )
373+ createConnection (connectionName , merged , settings , callback )
366374 key = promptKeys .pop ();
367375 Window ().show_input_panel (
368376 'Connection ' + key ,
0 commit comments