From 8ffe641ae18ff72faa0cbf1cc1be1e94f4e802d6 Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Fri, 21 May 2021 20:02:29 +0200 Subject: [PATCH] Fix d7074bb8344f2a1bce1d0491cccffe9631d0ed38 This fixes a bug introduced in d7074bb8344f2a1bce1d0491cccffe9631d0ed38. It turns out we cannot treat the edited table as similar to the other tables after all. --- src/ForeignKeyEditorDelegate.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ForeignKeyEditorDelegate.cpp b/src/ForeignKeyEditorDelegate.cpp index 0b0fc0e3..389a6ea3 100644 --- a/src/ForeignKeyEditorDelegate.cpp +++ b/src/ForeignKeyEditorDelegate.cpp @@ -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));