Skip to content

Commit 315019d

Browse files
committed
Improve foreign key editor when working on tables in non-main schemata
This improves commit 44eb2d4 by allowing to choose tables from other schemata than "main" in the foreign key editor in the Edit Table dialog. This still isn't perfect as only tables from the schema of the current table should be shown but with some care it should work for all use cases.
1 parent fbaf78e commit 315019d

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/ForeignKeyEditorDelegate.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,15 @@ ForeignKeyEditorDelegate::ForeignKeyEditorDelegate(const DBBrowserDB& db, sqlb::
8181
, m_db(db)
8282
, m_table(table)
8383
{
84-
const auto objects = m_db.getBrowsableObjects("main");
85-
for (auto& obj : objects) {
86-
if (obj->type() == sqlb::Object::Types::Table) {
87-
QString tableName = obj->name();
88-
m_tablesIds.insert(tableName, obj.dynamicCast<sqlb::Table>()->fieldNames());
84+
for(auto it=m_db.schemata.constBegin();it!=m_db.schemata.constEnd();++it)
85+
{
86+
for(auto jt=it->constBegin();jt!=it->constEnd();++jt)
87+
{
88+
if((*jt)->type() == sqlb::Object::Types::Table)
89+
{
90+
QString tableName = (*jt)->name();
91+
m_tablesIds.insert(tableName, (*jt).dynamicCast<sqlb::Table>()->fieldNames());
92+
}
8993
}
9094
}
9195
}

0 commit comments

Comments
 (0)