diff --git a/SQLTools.sublime-settings b/SQLTools.sublime-settings index c12b47e..753807f 100644 --- a/SQLTools.sublime-settings +++ b/SQLTools.sublime-settings @@ -20,6 +20,13 @@ * Completion keywords case is controlled by format.keyword_case (see below) */ "autocompletion": "smart", + /** + * Possible values for show_query: "top", "bottom", true ("top"), or false (disable) + * When using regular output, this will determine where query details is displayed. + * In stream output mode, any option that isn't false will print query details at + * the bottom of result. + */ + "show_query": false, /** * If DB cli binary is not in PATH, set the full path in "cli" section. * Note: forward slashes ("/") should be used in path. Example: @@ -37,10 +44,6 @@ "show_records": { "limit": 50 }, - "show_query": { - "enabled": false, - "placement": "top" - }, "format" : { "keyword_case" : "upper", "identifier_case" : null, diff --git a/SQLToolsAPI/Command.py b/SQLToolsAPI/Command.py index 0283da9..e1589fd 100644 --- a/SQLToolsAPI/Command.py +++ b/SQLToolsAPI/Command.py @@ -26,6 +26,12 @@ def __init__(self, args, env, callback, query=None, encoding='utf-8', self.silenceErrors = silenceErrors self.process = None + if 'show_query' not in self.options: + self.options['show_query'] = False + elif self.options['show_query'] not in ['top', 'bottom']: + self.options['show_query'] = 'top' if (isinstance(self.options['show_query'], bool) + and self.options['show_query']) else False + def run(self): if not self.query: return @@ -70,10 +76,9 @@ def run(self): if self.process: self.process.terminate() - if 'show_query' in self.options: - if 'enabled' in self.options['show_query'] and self.options['show_query']['enabled']: - formattedQueryInfo = self._formatShowQuery(self.query, queryTimerStart, queryTimerEnd) - self.callback(formattedQueryInfo + '\n') + if self.options['show_query']: + formattedQueryInfo = self._formatShowQuery(self.query, queryTimerStart, queryTimerEnd) + self.callback(formattedQueryInfo + '\n') return @@ -93,14 +98,13 @@ def run(self): resultString += errors.decode(self.encoding, 'replace').replace('\r', '') - if 'show_query' in self.options: - if 'enabled' in self.options['show_query'] and self.options['show_query']['enabled']: - formattedQueryInfo = self._formatShowQuery(self.query, queryTimerStart, queryTimerEnd) - queryPlacement = self.options['show_query'].get('placement', 'top') - if queryPlacement == 'top': - resultString = "{0}\n{1}".format(formattedQueryInfo, resultString) - elif queryPlacement == 'bottom': - resultString = "{0}{1}\n".format(resultString, formattedQueryInfo) + if self.options['show_query']: + formattedQueryInfo = self._formatShowQuery(self.query, queryTimerStart, queryTimerEnd) + queryPlacement = self.options['show_query'] + if queryPlacement == 'top': + resultString = "{0}\n{1}".format(formattedQueryInfo, resultString) + elif queryPlacement == 'bottom': + resultString = "{0}{1}\n".format(resultString, formattedQueryInfo) self.callback(resultString) diff --git a/SQLToolsAPI/Connection.py b/SQLToolsAPI/Connection.py index 2e83183..a2acba4 100644 --- a/SQLToolsAPI/Connection.py +++ b/SQLToolsAPI/Connection.py @@ -55,7 +55,7 @@ def __init__(self, name, options, settings=None, commandClass='ThreadCommand'): self.service = options.get('service', None) self.safe_limit = settings.get('safe_limit', None) - self.show_query = settings.get('show_query', {}) + self.show_query = settings.get('show_query', False) self.rowsLimit = settings.get('show_records', {}).get('limit', 50) self.cli = settings.get('cli')[options['type']]