Skip to content

Commit bcb0385

Browse files
committed
identifiers (schemas, tables, fields) added to DBManager sql windows completer list.
Thanks Silvio Grosso for the sponsorship.
1 parent 078f5b8 commit bcb0385

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

python/plugins/db_manager/completer.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,11 @@ def __init__(self, editor, db=None):
4040
wordlist = QStringList()
4141
for name, value in dictionary.iteritems():
4242
wordlist << value
43+
wordlist = QStringList() << list(set( wordlist )) # remove duplicates
4344

4445
# setup the completer
4546
QCompleter.__init__(self, sorted(wordlist), editor)
46-
self.setModelSorting(QCompleter.CaseInsensitivelySortedModel)
47+
self.setModelSorting(QCompleter.CaseSensitivelySortedModel)
4748
self.setWrapAround(False)
4849

4950
if isinstance(editor, CompletionTextEdit):

python/plugins/db_manager/db_plugins/postgis/connector.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -906,5 +906,17 @@ def connection_error_types(self):
906906

907907
def getSqlDictionary(self):
908908
from .sql_dictionary import getSqlDictionary
909-
return getSqlDictionary()
909+
sql_dict = getSqlDictionary()
910+
911+
# get schemas, tables and field names
912+
items = []
913+
sql = u"""SELECT nspname FROM pg_namespace WHERE nspname !~ '^pg_' AND nspname != 'information_schema'
914+
UNION SELECT relname FROM pg_class WHERE relkind IN ('v', 'r')
915+
UNION SELECT attname FROM pg_attribute WHERE attnum > 0"""
916+
c = self._execute(None, sql)
917+
for row in c.fetchall():
918+
items.append( row[0] )
919+
920+
sql_dict["identifier"] = items
921+
return sql_dict
910922

python/plugins/db_manager/db_plugins/spatialite/connector.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -593,5 +593,15 @@ def connection_error_types(self):
593593

594594
def getSqlDictionary(self):
595595
from .sql_dictionary import getSqlDictionary
596-
return getSqlDictionary()
596+
sql_dict = getSqlDictionary()
597+
598+
items = []
599+
for tbl in self.getTables():
600+
items.append( tbl[1] ) # table name
601+
602+
for fld in self.getTableFields( tbl[0] ):
603+
items.append( fld[1] ) # field name
604+
605+
sql_dict["identifier"] = items
606+
return sql_dict
597607

0 commit comments

Comments
 (0)