aboutsummaryrefslogtreecommitdiffstats
path: root/SQLiteStudio3/coreSQLiteStudio/services/impl
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2025-01-16 01:58:22 -0500
committerLibravatarUnit 193 <unit193@unit193.net>2025-01-16 01:58:22 -0500
commita5ae79be08125b31bb6b8d9703090a98c6fd2e30 (patch)
tree569ee612c9de85b2bb423efa485688ef1d43852e /SQLiteStudio3/coreSQLiteStudio/services/impl
parent21966b4f924b0a1933d9662e75ff253bd154fdb7 (diff)
parent81a21e6ce040e7740de86340c8ea4dba30e69bc3 (diff)
Update upstream source from tag 'upstream/3.4.13+dfsg'
Update to upstream version '3.4.13+dfsg' with Debian dir bf81ee0219cb8e4562a4751df17d75814772d2d6
Diffstat (limited to 'SQLiteStudio3/coreSQLiteStudio/services/impl')
-rw-r--r--SQLiteStudio3/coreSQLiteStudio/services/impl/collationmanagerimpl.cpp15
-rw-r--r--SQLiteStudio3/coreSQLiteStudio/services/impl/collationmanagerimpl.h1
-rw-r--r--SQLiteStudio3/coreSQLiteStudio/services/impl/configimpl.cpp11
-rw-r--r--SQLiteStudio3/coreSQLiteStudio/services/impl/configimpl.h1
-rw-r--r--SQLiteStudio3/coreSQLiteStudio/services/impl/dbmanagerimpl.cpp12
-rw-r--r--SQLiteStudio3/coreSQLiteStudio/services/impl/dbmanagerimpl.h1
-rw-r--r--SQLiteStudio3/coreSQLiteStudio/services/impl/functionmanagerimpl.cpp25
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);
}
}