mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
identifiers (schemas, tables, fields) added to DBManager sql windows completer list.
Thanks Silvio Grosso for the sponsorship.
This commit is contained in:
parent
078f5b846c
commit
bcb038504e
@ -40,10 +40,11 @@ class SqlCompleter(QCompleter):
|
||||
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 @@ class PostGisDBConnector(DBConnector):
|
||||
|
||||
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 @@ class SpatiaLiteDBConnector(DBConnector):
|
||||
|
||||
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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user