Skip to content

Commit

Permalink
Clean up and remove true/false evaluation for show_query
Browse files Browse the repository at this point in the history
  • Loading branch information
Coteh committed Jun 17, 2017
1 parent 2b4b23b commit d97073c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
11 changes: 5 additions & 6 deletions SQLTools.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -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
/**
Expand All @@ -38,8 +34,11 @@
"firebird": "isql",
"sqlite" : "sqlite3"
},
"show_records" : {
"limit" : 50
"show_records": {
"limit": 50
},
"show_query": {
"placement": "disabled"
},
"format" : {
"keyword_case" : "upper",
Expand Down
16 changes: 6 additions & 10 deletions SQLToolsAPI/Command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion SQLToolsAPI/Connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']]

Expand Down

0 comments on commit d97073c

Please sign in to comment.