Skip to content

Commit

Permalink
Add command to reset table, columns and functions cache
Browse files Browse the repository at this point in the history
  • Loading branch information
agvald committed Feb 6, 2018
1 parent 1fccdb0 commit 61f0751
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 61f0751

Please sign in to comment.