This fixes a bug introduced in d7074bb834.
It turns out we cannot treat the edited table as similar to the other
tables after all.
This commit is contained in:
Martin Kleusberg
2021-05-21 20:02:29 +02:00
parent 4c40400001
commit 8ffe641ae1

View File

@@ -84,7 +84,11 @@ ForeignKeyEditorDelegate::ForeignKeyEditorDelegate(const DBBrowserDB& db, sqlb::
for(const auto& it : m_db.schemata)
{
for(const auto& jt : it.second.tables)
m_tablesIds.insert({jt.first, jt.second->fieldNames()});
{
// Don't insert the current table into the list. The name and fields of the current table are always taken from the m_table reference
if(jt.first != m_table.name())
m_tablesIds.insert({jt.first, jt.second->fieldNames()});
}
}
}
@@ -120,6 +124,8 @@ QWidget* ForeignKeyEditorDelegate::createEditor(QWidget* parent, const QStyleOpt
});
editor->tablesComboBox->clear();
editor->tablesComboBox->addItem(QString::fromStdString(m_table.name())); // For recursive foreign keys
editor->tablesComboBox->insertSeparator(1);
for(const auto& i : m_tablesIds)
editor->tablesComboBox->addItem(QString::fromStdString(i.first));