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

Commit d97073c

Browse files
committed
Clean up and remove true/false evaluation for show_query
1 parent 2b4b23b commit d97073c

File tree

3 files changed

+12
-17
lines changed

3 files changed

+12
-17
lines changed

SQLTools.sublime-settings

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@
88
"show_result_on_window" : false,
99
"clear_output" : true,
1010
"safe_limit" : false,
11-
"show_query" : {
12-
"enabled": false,
13-
"placement": "top"
14-
},
1511
"expand_to_paragraph" : false,
1612
"use_streams" : false, // use streams for results
1713
/**
@@ -38,8 +34,11 @@
3834
"firebird": "isql",
3935
"sqlite" : "sqlite3"
4036
},
41-
"show_records" : {
42-
"limit" : 50
37+
"show_records": {
38+
"limit": 50
39+
},
40+
"show_query": {
41+
"placement": "disabled"
4342
},
4443
"format" : {
4544
"keyword_case" : "upper",

SQLToolsAPI/Command.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,13 @@ def run(self):
9393
'replace').replace('\r', '')
9494

9595
if 'show_query' in self.options:
96-
if isinstance(self.options['show_query'], dict):
97-
if 'enabled' not in self.options['show_query'] or self.options['show_query']['enabled']:
98-
formattedQueryInfo = self._formatShowQuery(self.query, queryTimerStart, queryTimerEnd)
99-
if ('placement' in self.options['show_query']
100-
and self.options['show_query']['placement'] == "bottom"):
101-
resultString = "{0}\n{1}".format(resultString, formattedQueryInfo)
102-
else: # top, by default
103-
resultString = "{0}\n{1}".format(formattedQueryInfo, resultString)
104-
elif isinstance(self.options['show_query'], bool) and self.options['show_query']:
96+
queryPlacement = self.options['show_query'].get('placement', 'disabled')
97+
if isinstance(queryPlacement, str) and queryPlacement != 'disabled':
10598
formattedQueryInfo = self._formatShowQuery(self.query, queryTimerStart, queryTimerEnd)
106-
resultString = "{0}\n{1}".format(formattedQueryInfo, resultString)
99+
if queryPlacement == 'top':
100+
resultString = "{0}\n{1}".format(formattedQueryInfo, resultString)
101+
elif queryPlacement == 'bottom':
102+
resultString = "{0}\n{1}".format(resultString, formattedQueryInfo)
107103

108104
self.callback(resultString)
109105

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', None)
58+
self.show_query = settings.get('show_query', {})
5959
self.rowsLimit = settings.get('show_records', {}).get('limit', 50)
6060
self.cli = settings.get('cli')[options['type']]
6161

0 commit comments

Comments
 (0)