diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -147,7 +147,7 @@ ############################ ########################### -set(KEXI_FRAMEWORKS_MIN_VERSION 3.1.0) +set(KEXI_FRAMEWORKS_MIN_VERSION 3.1.90) ## ## Test for KDb diff --git a/src/core/kexiproject.cpp b/src/core/kexiproject.cpp --- a/src/core/kexiproject.cpp +++ b/src/core/kexiproject.cpp @@ -1,6 +1,6 @@ /* This file is part of the KDE project Copyright (C) 2003 Lucijan Busch - Copyright (C) 2003-2016 Jarosław Staniek + Copyright (C) 2003-2018 Jarosław Staniek This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -793,6 +793,7 @@ int recentTypeId = -1000; QString pluginId; KexiPart::ItemDict *dict = 0; + QSet tableNamesSet; for (cursor->moveFirst(); !cursor->eof(); cursor->moveNext()) { bool ok; const int typeId = cursor->value(3).toInt(&ok); @@ -802,8 +803,9 @@ continue; } if (recentTypeId == typeId) { - if (pluginId.isEmpty()) // still the same unknown plugin ID + if (pluginId.isEmpty()) { // still the same unknown plugin ID continue; + } } else { // a new type ID: create another plugin items dict if it's an ID for a known type @@ -813,20 +815,44 @@ continue; dict = new KexiPart::ItemDict(); d->itemDicts.insert(pluginId, dict); + if (typeId == KDb::TableObjectType) { + // Starting to load table names: initialize. + // This list since 3.2 does not contain names without physical tables so we can + // catch these cases below. + const QStringList tableNames(d->connection->tableNames(false /*public*/, &ok)); + if (!ok) { + m_result = KDbResult(ERR_OBJECT_NOT_FOUND, xi18n("Could not load list of tables.")); + qDeleteAll(d->itemDicts); + return false; + } + for (const QString &name : tableNames) { + tableNamesSet.insert(name.toLower()); + } + } } const int ident = cursor->value(0).toInt(&ok); const QString objName(cursor->value(1).toString()); - if (ok && (ident > 0) && !d->connection->isInternalTableSchema(objName) - && KDb::isIdentifier(objName)) + if (!ok || ident <= 0 || !KDb::isIdentifier(objName)) { - KexiPart::Item *it = new KexiPart::Item(); - it->setIdentifier(ident); - it->setPluginId(pluginId); - it->setName(objName); - it->setCaption(cursor->value(2).toString()); - dict->insert(it->identifier(), it); + continue; // invalid ID or invalid name + } + if (typeId == KDb::TableObjectType) { + if (d->connection->isInternalTableSchema(objName)) { + qInfo() << "table" << objName << "id=" << ident << "is internal, skipping"; + continue; + } + if (!tableNamesSet.contains(objName.toLower())) { + qInfo() << "table" << objName << "id=" << ident + << "does not correspondent with physical table"; + continue; + } } - //qDebug() << "ITEM ADDED == "<