Skip to content

Commit 6143925

Browse files
committed
Fix handling of databases with a view and a trigger with the same name
This fixes editing and browsing views which have the same name as a trigger in the same database. See issue #2091.
1 parent 2888530 commit 6143925

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/DbStructureModel.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,9 @@ void DbStructureModel::buildTree(QTreeWidgetItem* parent, const std::string& sch
341341
itemTriggers->setText(ColumnName, tr("Triggers (%1)").arg(calc_number_of_objects_by_type(objmap, "trigger")));
342342
typeToParentItem.insert({"trigger", itemTriggers});
343343

344-
// Get all database objects and sort them by their name
345-
std::map<std::string, sqlb::ObjectPtr> dbobjs;
344+
// Get all database objects and sort them by their name.
345+
// This needs to be a multimap because SQLite allows views and triggers with the same name which means that names can appear twice.
346+
std::multimap<std::string, sqlb::ObjectPtr> dbobjs;
346347
for(const auto& it : objmap)
347348
dbobjs.insert({it.second->name(), it.second});
348349

0 commit comments

Comments
 (0)