From d97073c481c10e156209405c567965d45be265a3 Mon Sep 17 00:00:00 2001 From: Coteh Date: Sat, 17 Jun 2017 14:38:47 -0400 Subject: [PATCH] Clean up and remove true/false evaluation for show_query --- SQLTools.sublime-settings | 11 +++++------ SQLToolsAPI/Command.py | 16 ++++++---------- SQLToolsAPI/Connection.py | 2 +- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/SQLTools.sublime-settings b/SQLTools.sublime-settings index e578a38..4bd5fd8 100644 --- a/SQLTools.sublime-settings +++ b/SQLTools.sublime-settings @@ -8,10 +8,6 @@ "show_result_on_window" : false, "clear_output" : true, "safe_limit" : false, - "show_query" : { - "enabled": false, - "placement": "top" - }, "expand_to_paragraph" : false, "use_streams" : false, // use streams for results /** @@ -38,8 +34,11 @@ "firebird": "isql", "sqlite" : "sqlite3" }, - "show_records" : { - "limit" : 50 + "show_records": { + "limit": 50 + }, + "show_query": { + "placement": "disabled" }, "format" : { "keyword_case" : "upper", diff --git a/SQLToolsAPI/Command.py b/SQLToolsAPI/Command.py index b027992..5a28589 100644 --- a/SQLToolsAPI/Command.py +++ b/SQLToolsAPI/Command.py @@ -93,17 +93,13 @@ def run(self): 'replace').replace('\r', '') if 'show_query' in self.options: - if isinstance(self.options['show_query'], dict): - if 'enabled' not in self.options['show_query'] or self.options['show_query']['enabled']: - formattedQueryInfo = self._formatShowQuery(self.query, queryTimerStart, queryTimerEnd) - if ('placement' in self.options['show_query'] - and self.options['show_query']['placement'] == "bottom"): - resultString = "{0}\n{1}".format(resultString, formattedQueryInfo) - else: # top, by default - resultString = "{0}\n{1}".format(formattedQueryInfo, resultString) - elif isinstance(self.options['show_query'], bool) and self.options['show_query']: + queryPlacement = self.options['show_query'].get('placement', 'disabled') + if isinstance(queryPlacement, str) and queryPlacement != 'disabled': formattedQueryInfo = self._formatShowQuery(self.query, queryTimerStart, queryTimerEnd) - resultString = "{0}\n{1}".format(formattedQueryInfo, resultString) + if queryPlacement == 'top': + resultString = "{0}\n{1}".format(formattedQueryInfo, resultString) + elif queryPlacement == 'bottom': + resultString = "{0}\n{1}".format(resultString, formattedQueryInfo) self.callback(resultString) diff --git a/SQLToolsAPI/Connection.py b/SQLToolsAPI/Connection.py index 7971ec0..2e83183 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', None) + self.show_query = settings.get('show_query', {}) self.rowsLimit = settings.get('show_records', {}).get('limit', 50) self.cli = settings.get('cli')[options['type']]