Skip to content
This repository was archived by the owner on Mar 12, 2020. It is now read-only.

Commit 3a5a00f

Browse files
committed
Use simple bool/string value for show_query, for backwards compatibility
1 parent 453569f commit 3a5a00f

3 files changed

Lines changed: 24 additions & 17 deletions

File tree

SQLTools.sublime-settings

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@
2020
* Completion keywords case is controlled by format.keyword_case (see below)
2121
*/
2222
"autocompletion": "smart",
23+
/**
24+
* Possible values for show_query: "top", "bottom", true ("top"), or false (disable)
25+
* When using regular output, this will determine where query details is displayed.
26+
* In stream output mode, any option that isn't false will print query details at
27+
* the bottom of result.
28+
*/
29+
"show_query": false,
2330
/**
2431
* If DB cli binary is not in PATH, set the full path in "cli" section.
2532
* Note: forward slashes ("/") should be used in path. Example:
@@ -37,10 +44,6 @@
3744
"show_records": {
3845
"limit": 50
3946
},
40-
"show_query": {
41-
"enabled": false,
42-
"placement": "top"
43-
},
4447
"format" : {
4548
"keyword_case" : "upper",
4649
"identifier_case" : null,

SQLToolsAPI/Command.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ def __init__(self, args, env, callback, query=None, encoding='utf-8',
2626
self.silenceErrors = silenceErrors
2727
self.process = None
2828

29+
if 'show_query' not in self.options:
30+
self.options['show_query'] = False
31+
elif self.options['show_query'] not in ['top', 'bottom']:
32+
self.options['show_query'] = 'top' if (isinstance(self.options['show_query'], bool)
33+
and self.options['show_query']) else False
34+
2935
def run(self):
3036
if not self.query:
3137
return
@@ -70,10 +76,9 @@ def run(self):
7076
if self.process:
7177
self.process.terminate()
7278

73-
if 'show_query' in self.options:
74-
if 'enabled' in self.options['show_query'] and self.options['show_query']['enabled']:
75-
formattedQueryInfo = self._formatShowQuery(self.query, queryTimerStart, queryTimerEnd)
76-
self.callback(formattedQueryInfo + '\n')
79+
if self.options['show_query']:
80+
formattedQueryInfo = self._formatShowQuery(self.query, queryTimerStart, queryTimerEnd)
81+
self.callback(formattedQueryInfo + '\n')
7782

7883
return
7984

@@ -93,14 +98,13 @@ def run(self):
9398
resultString += errors.decode(self.encoding,
9499
'replace').replace('\r', '')
95100

96-
if 'show_query' in self.options:
97-
if 'enabled' in self.options['show_query'] and self.options['show_query']['enabled']:
98-
formattedQueryInfo = self._formatShowQuery(self.query, queryTimerStart, queryTimerEnd)
99-
queryPlacement = self.options['show_query'].get('placement', 'top')
100-
if queryPlacement == 'top':
101-
resultString = "{0}\n{1}".format(formattedQueryInfo, resultString)
102-
elif queryPlacement == 'bottom':
103-
resultString = "{0}{1}\n".format(resultString, formattedQueryInfo)
101+
if self.options['show_query']:
102+
formattedQueryInfo = self._formatShowQuery(self.query, queryTimerStart, queryTimerEnd)
103+
queryPlacement = self.options['show_query']
104+
if queryPlacement == 'top':
105+
resultString = "{0}\n{1}".format(formattedQueryInfo, resultString)
106+
elif queryPlacement == 'bottom':
107+
resultString = "{0}{1}\n".format(resultString, formattedQueryInfo)
104108

105109
self.callback(resultString)
106110

SQLToolsAPI/Connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def __init__(self, name, options, settings=None, commandClass='ThreadCommand'):
5555
self.service = options.get('service', None)
5656

5757
self.safe_limit = settings.get('safe_limit', None)
58-
self.show_query = settings.get('show_query', {})
58+
self.show_query = settings.get('show_query', False)
5959
self.rowsLimit = settings.get('show_records', {}).get('limit', 50)
6060
self.cli = settings.get('cli')[options['type']]
6161

0 commit comments

Comments
 (0)