diff options
Diffstat (limited to 'SQLiteStudio3/coreSQLiteStudio/services/impl')
7 files changed, 55 insertions, 11 deletions
diff --git a/SQLiteStudio3/coreSQLiteStudio/services/impl/collationmanagerimpl.cpp b/SQLiteStudio3/coreSQLiteStudio/services/impl/collationmanagerimpl.cpp index 1cdc59f..668eb72 100644 --- a/SQLiteStudio3/coreSQLiteStudio/services/impl/collationmanagerimpl.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/services/impl/collationmanagerimpl.cpp @@ -34,6 +34,16 @@ QList<CollationManager::CollationPtr> CollationManagerImpl::getAllCollations() c return collations; } +CollationManager::CollationPtr CollationManagerImpl::getCollation(const QString &name) const +{ + if (!collationsByKey.contains(name)) + { + qCritical() << "Could not find requested collation" << name << "."; + return nullptr; + } + return collationsByKey[name]; +} + QList<CollationManager::CollationPtr> CollationManagerImpl::getCollationsForDatabase(const QString& dbName) const { QList<CollationPtr> results; @@ -98,6 +108,7 @@ void CollationManagerImpl::storeInConfig() for (CollationPtr coll : collations) { collHash["name"] = coll->name; + collHash["type"] = coll->type; collHash["lang"] = coll->lang; collHash["code"] = coll->code; collHash["allDatabases"] = coll->allDatabases; @@ -119,6 +130,10 @@ void CollationManagerImpl::loadFromConfig() collHash = var.toHash(); coll = CollationPtr::create(); coll->name = collHash["name"].toString(); + if (collHash.contains("type") && collHash["type"].toInt() == CollationType::EXTENSION_BASED) + coll->type = CollationType::EXTENSION_BASED; + else + coll->type = CollationType::FUNCTION_BASED; coll->lang = updateScriptingQtLang(collHash["lang"].toString()); coll->code = collHash["code"].toString(); coll->databases = collHash["databases"].toStringList(); diff --git a/SQLiteStudio3/coreSQLiteStudio/services/impl/collationmanagerimpl.h b/SQLiteStudio3/coreSQLiteStudio/services/impl/collationmanagerimpl.h index 27adffb..5ce47c6 100644 --- a/SQLiteStudio3/coreSQLiteStudio/services/impl/collationmanagerimpl.h +++ b/SQLiteStudio3/coreSQLiteStudio/services/impl/collationmanagerimpl.h @@ -17,6 +17,7 @@ class API_EXPORT CollationManagerImpl : public CollationManager QList<CollationPtr> getCollationsForDatabase(const QString& dbName) const; int evaluate(const QString& name, const QString& value1, const QString& value2); int evaluateDefault(const QString& value1, const QString& value2); + CollationPtr getCollation(const QString &name) const; private: void init(); diff --git a/SQLiteStudio3/coreSQLiteStudio/services/impl/configimpl.cpp b/SQLiteStudio3/coreSQLiteStudio/services/impl/configimpl.cpp index a7f8d2b..bcd6df8 100644 --- a/SQLiteStudio3/coreSQLiteStudio/services/impl/configimpl.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/services/impl/configimpl.cpp @@ -478,6 +478,7 @@ QVariant ConfigImpl::getPopulateHistory(const QString& pluginName) const void ConfigImpl::addDdlHistory(const QString& queries, const QString& dbName, const QString& dbFile) { + ddlHistoryMutex.lock(); QtConcurrent::run(this, &ConfigImpl::asyncAddDdlHistory, queries, dbName, dbFile); } @@ -1030,6 +1031,7 @@ void ConfigImpl::asyncAddDdlHistory(const QString& queries, const QString& dbNam } } db->commit(); + ddlHistoryMutex.unlock(); emit ddlHistoryRefreshNeeded(); } @@ -1122,12 +1124,19 @@ void ConfigImpl::updateConfigDb() // 1->2 db->exec("UPDATE settings SET [key] = 'DataUncommittedError' WHERE [key] = 'DataUncommitedError'"); db->exec("UPDATE settings SET [key] = 'DataUncommitted' WHERE [key] = 'DataUncommited'"); - __attribute__((__fallthrough__)); + [[fallthrough]]; } case 2: { // 2->3 db->exec("ALTER TABLE groups ADD db_expanded INTEGER DEFAULT 0"); + [[fallthrough]]; + } + case 3: + { + // 3->4 + db->exec("DELETE FROM settings WHERE [group] = 'DialogDimensions'"); // #5161 + //[[fallthrough]]; } // Add cases here for next versions, // without a "break" instruction, diff --git a/SQLiteStudio3/coreSQLiteStudio/services/impl/configimpl.h b/SQLiteStudio3/coreSQLiteStudio/services/impl/configimpl.h index 9f0f36e..14d42e0 100644 --- a/SQLiteStudio3/coreSQLiteStudio/services/impl/configimpl.h +++ b/SQLiteStudio3/coreSQLiteStudio/services/impl/configimpl.h @@ -154,6 +154,7 @@ class API_EXPORT ConfigImpl : public Config SqlHistoryModel* sqlHistoryModel = nullptr; DdlHistoryModel* ddlHistoryModel = nullptr; QMutex sqlHistoryMutex; + QMutex ddlHistoryMutex; QString sqlite3Version; public slots: diff --git a/SQLiteStudio3/coreSQLiteStudio/services/impl/dbmanagerimpl.cpp b/SQLiteStudio3/coreSQLiteStudio/services/impl/dbmanagerimpl.cpp index 6258f71..46c8178 100644 --- a/SQLiteStudio3/coreSQLiteStudio/services/impl/dbmanagerimpl.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/services/impl/dbmanagerimpl.cpp @@ -247,6 +247,18 @@ QStringList DbManagerImpl::getDbNames() return nameToDb.keys(); } +QStringList DbManagerImpl::getValidDbNames() +{ + QReadLocker lock(&listLock); + QStringList result; + for (Db* db : dbList) + { + if (db->isValid()) + result << db->getName(); + } + return result; +} + Db* DbManagerImpl::getByName(const QString &name, Qt::CaseSensitivity cs) { QReadLocker lock(&listLock); diff --git a/SQLiteStudio3/coreSQLiteStudio/services/impl/dbmanagerimpl.h b/SQLiteStudio3/coreSQLiteStudio/services/impl/dbmanagerimpl.h index 5f99f86..867dd92 100644 --- a/SQLiteStudio3/coreSQLiteStudio/services/impl/dbmanagerimpl.h +++ b/SQLiteStudio3/coreSQLiteStudio/services/impl/dbmanagerimpl.h @@ -40,6 +40,7 @@ class API_EXPORT DbManagerImpl : public DbManager QList<Db*> getValidDbList(); QList<Db*> getConnectedDbList(); QStringList getDbNames(); + QStringList getValidDbNames(); Db* getByName(const QString& name, Qt::CaseSensitivity cs = Qt::CaseInsensitive); Db* getByPath(const QString& path); Db* createInMemDb(bool pureInit = false); diff --git a/SQLiteStudio3/coreSQLiteStudio/services/impl/functionmanagerimpl.cpp b/SQLiteStudio3/coreSQLiteStudio/services/impl/functionmanagerimpl.cpp index 1b49f3b..ef0fbc9 100644 --- a/SQLiteStudio3/coreSQLiteStudio/services/impl/functionmanagerimpl.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/services/impl/functionmanagerimpl.cpp @@ -721,35 +721,40 @@ QVariant FunctionManagerImpl::nativeImport(const QList<QVariant> &args, Db *db, ImportManager::StandardImportConfig stdConfig; stdConfig.inputFileName = args[0].toString(); stdConfig.ignoreErrors = true; - stdConfig.skipTransaction = true; + stdConfig.noDbLock = true; if (args.size() > 3) stdConfig.codec = args[3].toString(); if (args.size() > 4) { // Parsing plugin options - int idx; - QString option; - QString value; - CfgEntry* cfg; QStringList lines = args[4].toString().split(QRegExp("[\r\n]+")); for (const QString& line : lines) { - idx = line.indexOf("="); + int idx = line.indexOf("="); if (idx == -1) { qDebug() << "Invalid options entry for import() function call:" << line; continue; } - option = line.left(idx).trimmed(); - cfg = CfgMain::getEntryByPath(option); + QString option = line.left(idx).trimmed(); + CfgEntry* cfg = CfgMain::getEntryByPath(option); if (!cfg) { qDebug() << "Invalid option name for import() function call:" << option; continue; } - value = line.mid(idx + 1); - cfg->set(value); + + QVariant varValue = line.mid(idx + 1); + QVariant defValue = cfg->getDefaultValue(); + QVariant::Type expectedType = defValue.type(); + if (varValue.type() != expectedType && !varValue.convert(expectedType)) + { + qDebug() << "Invalid option value for import() function call:" << option << ", invalid value was:" << varValue.toString() + << ", expected value type was:" << defValue.typeName() << ", but given value could not be converted to that type."; + continue; + } + cfg->set(varValue); } } |
