Skip to content

Commit

Permalink
Merge pull request mtxr#189 from agvald/master
Browse files Browse the repository at this point in the history
Well done!
  • Loading branch information
mtxr authored Feb 6, 2018
2 parents 1fccdb0 + 61f0751 commit 376a727
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Default.sublime-commands
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
"caption": "ST: Function Description",
"command": "st_desc_function"
},
{
"caption": "ST: Remove Table and Functions cache",
"command": "st_clear_cache"
},
{
"caption": "ST: Save Query",
"command": "st_save_query"
Expand Down
14 changes: 12 additions & 2 deletions SQLTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,15 +345,19 @@ def setConnection(index, tablesCallback=None, columnsCallback=None, functionsCal
connListNames = list(ST.connectionList.keys())
connListNames.sort()
ST.conn = ST.connectionList.get(connListNames[index])
ST.reset_cache(tablesCallback, columnsCallback, functionsCallback)

Log('Connection {0} selected'.format(ST.conn))

@staticmethod
def reset_cache(tablesCallback=None, columnsCallback=None, functionsCallback=None):
# clear list of identifiers in case connection is changed
ST.tables = []
ST.columns = []
ST.functions = []

ST.loadConnectionData(tablesCallback, columnsCallback, functionsCallback)

Log('Connection {0} selected'.format(ST.conn))

@staticmethod
def selectConnection(tablesCallback=None, columnsCallback=None, functionsCallback=None):
ST.connectionList = getConnections()
Expand Down Expand Up @@ -540,6 +544,12 @@ def cb(index):
# from "function_name(int)"
ST.selectFunction(cb)

class StClearCache(WindowCommand):
@staticmethod
def run():
if not ST.conn:
return
ST.reset_cache()

class StExplainPlan(WindowCommand):
@staticmethod
Expand Down

0 comments on commit 376a727

Please sign in to comment.