Auto-completion for column names in the SQL editor

Isolated column names are added to the list of possible auto-completions,
so they can be completed without having to enter first the table followed
by dot. "Table.field" completion is still supported for completing only for
fields inside that context.

See issue #1242
This commit is contained in:
mgrojo
2018-01-18 22:55:59 +01:00
parent 7d1ddbd717
commit 4b3780e22a
+5 -1
View File
@@ -138,10 +138,14 @@ void SqlUiLexer::setTableNames(const TablesAndColumnsMap& tables)
setupAutoCompletion();
for(auto it=tables.constBegin();it!=tables.constEnd();++it)
{
for(const QString& field : it.value())
for(const QString& field : it.value()) {
// Completion for table.field
autocompleteApi->add(it.key() + "?" + QString::number(SqlUiLexer::ApiCompleterIconIdTable) + "." +
field + "?" + QString::number(SqlUiLexer::ApiCompleterIconIdColumn));
// Completion for isolated field
autocompleteApi->add(field + "?" + QString::number(SqlUiLexer::ApiCompleterIconIdColumn));
}
// Store the table name list in order to highlight them in a different colour
listTables.append(it.key());
}