Skip to content

Commit

Permalink
identifiers (schemas, tables, fields) added to DBManager sql windows …
Browse files Browse the repository at this point in the history
…completer list.

Thanks Silvio Grosso for the sponsorship.
  • Loading branch information
brushtyler committed Aug 27, 2012
1 parent 078f5b8 commit bcb0385
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
3 changes: 2 additions & 1 deletion python/plugins/db_manager/completer.py
Expand Up @@ -40,10 +40,11 @@ def __init__(self, editor, db=None):
wordlist = QStringList()
for name, value in dictionary.iteritems():
wordlist << value
wordlist = QStringList() << list(set( wordlist )) # remove duplicates

# setup the completer
QCompleter.__init__(self, sorted(wordlist), editor)
self.setModelSorting(QCompleter.CaseInsensitivelySortedModel)
self.setModelSorting(QCompleter.CaseSensitivelySortedModel)
self.setWrapAround(False)

if isinstance(editor, CompletionTextEdit):
Expand Down
14 changes: 13 additions & 1 deletion python/plugins/db_manager/db_plugins/postgis/connector.py
Expand Up @@ -906,5 +906,17 @@ def connection_error_types(self):

def getSqlDictionary(self):
from .sql_dictionary import getSqlDictionary
return getSqlDictionary()
sql_dict = getSqlDictionary()

# get schemas, tables and field names
items = []
sql = u"""SELECT nspname FROM pg_namespace WHERE nspname !~ '^pg_' AND nspname != 'information_schema'
UNION SELECT relname FROM pg_class WHERE relkind IN ('v', 'r')
UNION SELECT attname FROM pg_attribute WHERE attnum > 0"""
c = self._execute(None, sql)
for row in c.fetchall():
items.append( row[0] )

sql_dict["identifier"] = items
return sql_dict

12 changes: 11 additions & 1 deletion python/plugins/db_manager/db_plugins/spatialite/connector.py
Expand Up @@ -593,5 +593,15 @@ def connection_error_types(self):

def getSqlDictionary(self):
from .sql_dictionary import getSqlDictionary
return getSqlDictionary()
sql_dict = getSqlDictionary()

items = []
for tbl in self.getTables():
items.append( tbl[1] ) # table name

for fld in self.getTableFields( tbl[0] ):
items.append( fld[1] ) # field name

sql_dict["identifier"] = items
return sql_dict

0 comments on commit bcb0385

Please sign in to comment.