Skip to content
Permalink
Browse files

identifiers (schemas, tables, fields) added to DBManager sql windows …

…completer list.

Thanks Silvio Grosso for the sponsorship.
  • Loading branch information
brushtyler committed Aug 27, 2012
1 parent 078f5b8 commit bcb038504e2954a476ed2f5e3d2114d7257a0109
@@ -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):
@@ -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

@@ -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.
You can’t perform that action at this time.