Support SQL auto-completion for tables from different schemata

This improves commit 44eb2d4f99 by adding
support for auto completion in the SQL editors for all tables that are
not in the "main" schema.
This commit is contained in:
Martin Kleusberg
2017-09-04 10:25:05 +02:00
parent 315019dd9c
commit 1a3e3d3c40

View File

@@ -390,15 +390,18 @@ void MainWindow::populateStructure()
return;
// Update table and column names for syntax highlighting
objectMap tab = db.getBrowsableObjects("main");
SqlUiLexer::TablesAndColumnsMap tablesToColumnsMap;
for(auto it=tab.constBegin();it!=tab.constEnd();++it)
for(auto it=db.schemata.constBegin();it!=db.schemata.constEnd();++it)
{
QString objectname = (*it)->name();
objectMap tab = db.getBrowsableObjects(it.key());
for(auto it=tab.constBegin();it!=tab.constEnd();++it)
{
QString objectname = (*it)->name();
sqlb::FieldInfoList fi = (*it)->fieldInformation();
foreach(const sqlb::FieldInfo& f, fi)
tablesToColumnsMap[objectname].append(f.name);
sqlb::FieldInfoList fi = (*it)->fieldInformation();
foreach(const sqlb::FieldInfo& f, fi)
tablesToColumnsMap[objectname].append(f.name);
}
}
SqlTextEdit::sqlLexer->setTableNames(tablesToColumnsMap);
ui->editLogApplication->reloadKeywords();