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.
This commit is contained in:
Martin Kleusberg
2020-01-16 17:35:12 +01:00
parent 2888530a10
commit 6143925d7e

View File

@@ -341,8 +341,9 @@ void DbStructureModel::buildTree(QTreeWidgetItem* parent, const std::string& sch
itemTriggers->setText(ColumnName, tr("Triggers (%1)").arg(calc_number_of_objects_by_type(objmap, "trigger")));
typeToParentItem.insert({"trigger", itemTriggers});
// Get all database objects and sort them by their name
std::map<std::string, sqlb::ObjectPtr> dbobjs;
// Get all database objects and sort them by their name.
// This needs to be a multimap because SQLite allows views and triggers with the same name which means that names can appear twice.
std::multimap<std::string, sqlb::ObjectPtr> dbobjs;
for(const auto& it : objmap)
dbobjs.insert({it.second->name(), it.second});