Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Rename in KisSqlQueryLoader: prepare_only -> single_statement_mode

Dmitry Kazakov2ac0ebac8f3a
diff --git a/libs/resources/KisResourceCacheDb.cpp b/libs/resources/KisResourceCacheDb.cpp
index 5478d602b8..08bedea989 100644
--- a/libs/resources/KisResourceCacheDb.cpp
+++ b/libs/resources/KisResourceCacheDb.cpp
@@ -1693,14 +1693,14 @@ bool KisResourceCacheDb::deleteStorage(QString location)
{
KisSqlQueryLoader loader(":/sql/delete_versioned_resources_for_storage_indirect.sql",
- KisSqlQueryLoader::prepare_only);
+ KisSqlQueryLoader::single_statement_mode);
loader.query().bindValue(":location", changeToEmptyIfNull(location));
loader.exec();
}
{
KisSqlQueryLoader loader(":/sql/delete_versioned_resources_for_storage_direct.sql",
- KisSqlQueryLoader::prepare_only);
+ KisSqlQueryLoader::single_statement_mode);
loader.query().bindValue(":location", changeToEmptyIfNull(location));
loader.exec();
if (loader.query().numRowsAffected() > 0) {
@@ -1712,7 +1712,7 @@ bool KisResourceCacheDb::deleteStorage(QString location)
{
KisSqlQueryLoader loader(":/sql/delete_resource_metadata_for_storage.sql",
- KisSqlQueryLoader::prepare_only);
+ KisSqlQueryLoader::single_statement_mode);
loader.query().bindValue(":location", changeToEmptyIfNull(location));
loader.query().bindValue(":table", METADATA_RESOURCES);
loader.exec();
@@ -1724,7 +1724,7 @@ bool KisResourceCacheDb::deleteStorage(QString location)
"WHERE storage_id = (SELECT storages.id\n"
" FROM storages\n"
" WHERE storages.location = :location)\n",
- KisSqlQueryLoader::prepare_only);
+ KisSqlQueryLoader::single_statement_mode);
loader.query().bindValue(":location", changeToEmptyIfNull(location));
loader.exec();
}
@@ -1739,7 +1739,7 @@ bool KisResourceCacheDb::deleteStorage(QString location)
" FROM storages\n"
" WHERE storages.location = :location)\n"
" )",
- KisSqlQueryLoader::prepare_only);
+ KisSqlQueryLoader::single_statement_mode);
loader.query().bindValue(":location", changeToEmptyIfNull(location));
loader.exec();
}
@@ -1751,7 +1751,7 @@ bool KisResourceCacheDb::deleteStorage(QString location)
" (SELECT storages.id\n"
" FROM storages\n"
" WHERE storages.location = :location)",
- KisSqlQueryLoader::prepare_only);
+ KisSqlQueryLoader::single_statement_mode);
loader.query().bindValue(":location", changeToEmptyIfNull(location));
loader.exec();
}
@@ -1763,7 +1763,7 @@ bool KisResourceCacheDb::deleteStorage(QString location)
" FROM storages\n"
" WHERE storages.location = :location)"
"AND table_name = :table;",
- KisSqlQueryLoader::prepare_only);
+ KisSqlQueryLoader::single_statement_mode);
loader.query().bindValue(":location", changeToEmptyIfNull(location));
loader.query().bindValue(":table", METADATA_STORAGES);
loader.exec();
@@ -1773,7 +1773,7 @@ bool KisResourceCacheDb::deleteStorage(QString location)
KisSqlQueryLoader loader("inline://delete_storage",
"DELETE FROM storages\n"
"WHERE location = :location;",
- KisSqlQueryLoader::prepare_only);
+ KisSqlQueryLoader::single_statement_mode);
loader.query().bindValue(":location", changeToEmptyIfNull(location));
loader.exec();
}
@@ -2130,7 +2130,7 @@ void KisResourceCacheDb::deleteTemporaryResources()
" FROM storages\n"
" WHERE storage_type_id == :storage_type))\n"
"AND table_name = :table",
- KisSqlQueryLoader::prepare_only);
+ KisSqlQueryLoader::single_statement_mode);
loader.query().bindValue(":table", METADATA_RESOURCES);
loader.query().bindValue(":storage_type", (int)KisResourceStorage::StorageType::Memory);
loader.exec();
@@ -2143,7 +2143,7 @@ void KisResourceCacheDb::deleteTemporaryResources()
" FROM resources\n"
" WHERE temporary = 1)\n"
"AND table_name = :table",
- KisSqlQueryLoader::prepare_only);
+ KisSqlQueryLoader::single_statement_mode);
loader.query().bindValue(":table", METADATA_RESOURCES);
loader.exec();
}
@@ -2154,7 +2154,7 @@ void KisResourceCacheDb::deleteTemporaryResources()
"WHERE storage_id in (SELECT id\n"
" FROM storages\n"
" WHERE storage_type_id == :storage_type)",
- KisSqlQueryLoader::prepare_only);
+ KisSqlQueryLoader::single_statement_mode);
loader.query().bindValue(":storage_type", (int)KisResourceStorage::StorageType::Memory);
loader.exec();
}
@@ -2164,7 +2164,7 @@ void KisResourceCacheDb::deleteTemporaryResources()
"DELETE FROM versioned_resources\n"
"WHERE resource_id IN (SELECT id FROM resources\n"
" WHERE temporary = 1)",
- KisSqlQueryLoader::prepare_only);
+ KisSqlQueryLoader::single_statement_mode);
loader.exec();
}
@@ -2174,7 +2174,7 @@ void KisResourceCacheDb::deleteTemporaryResources()
"WHERE storage_id in (SELECT id\n"
" FROM storages\n"
" WHERE storage_type_id == :storage_type)",
- KisSqlQueryLoader::prepare_only);
+ KisSqlQueryLoader::single_statement_mode);
loader.query().bindValue(":storage_type", (int)KisResourceStorage::StorageType::Memory);
loader.exec();
}
@@ -2183,7 +2183,7 @@ void KisResourceCacheDb::deleteTemporaryResources()
KisSqlQueryLoader loader("inline://delete_current_temporary_resources",
"DELETE FROM resources\n"
"WHERE temporary = 1",
- KisSqlQueryLoader::prepare_only);
+ KisSqlQueryLoader::single_statement_mode);
loader.exec();
}
@@ -2198,7 +2198,7 @@ void KisResourceCacheDb::deleteTemporaryResources()
" FROM storages\n"
" WHERE storage_type_id == :storage_type)\n"
"AND table_name = :table;",
- KisSqlQueryLoader::prepare_only);
+ KisSqlQueryLoader::single_statement_mode);
loader.query().bindValue(":storage_type", (int)KisResourceStorage::StorageType::Memory);
loader.query().bindValue(":table", METADATA_STORAGES);
loader.exec();
@@ -2208,7 +2208,7 @@ void KisResourceCacheDb::deleteTemporaryResources()
KisSqlQueryLoader loader("inline://delete_temporary_storages",
"DELETE FROM storages\n"
"WHERE storage_type_id == :storage_type\n",
- KisSqlQueryLoader::prepare_only);
+ KisSqlQueryLoader::single_statement_mode);
loader.query().bindValue(":storage_type", (int)KisResourceStorage::StorageType::Memory);
loader.exec();
}
diff --git a/libs/resources/KisSqlQueryLoader.cpp b/libs/resources/KisSqlQueryLoader.cpp
index 378177d9d6..4a57df6a0b 100644
--- a/libs/resources/KisSqlQueryLoader.cpp
+++ b/libs/resources/KisSqlQueryLoader.cpp
@@ -75,7 +75,7 @@ KisSqlQueryLoader::KisSqlQueryLoader(const QString &fileName)
}
}
-KisSqlQueryLoader::KisSqlQueryLoader(const QString &fileName, prepare_only_t)
+KisSqlQueryLoader::KisSqlQueryLoader(const QString &fileName, single_statement_mode_t)
{
QFile file(fileName);
if (file.open(QFile::ReadOnly)) {
@@ -90,7 +90,7 @@ KisSqlQueryLoader::KisSqlQueryLoader(const QString &scriptName, const QString &s
init(scriptName, script, false);
}
-KisSqlQueryLoader::KisSqlQueryLoader(const QString &scriptName, const QString &script, prepare_only_t)
+KisSqlQueryLoader::KisSqlQueryLoader(const QString &scriptName, const QString &script, single_statement_mode_t)
{
init(scriptName, script, true);
}
diff --git a/libs/resources/KisSqlQueryLoader.h b/libs/resources/KisSqlQueryLoader.h
index d85326f89e..83f62bdd84 100644
--- a/libs/resources/KisSqlQueryLoader.h
+++ b/libs/resources/KisSqlQueryLoader.h
@@ -105,8 +105,8 @@
class KRITARESOURCES_EXPORT KisSqlQueryLoader
{
public:
- struct prepare_only_t {};
- static constexpr prepare_only_t prepare_only{};
+ struct single_statement_mode_t {};
+ static constexpr single_statement_mode_t single_statement_mode{};
struct FileException : std::exception
{
@@ -158,7 +158,7 @@ public:
* mode the loader immediately prepares the query, which means you can bind any
* values to the query before calling exec().
*/
- KisSqlQueryLoader(const QString &fileName, prepare_only_t);
+ KisSqlQueryLoader(const QString &fileName, single_statement_mode_t);
/**
* Load the script from an explicit string \p script. \p scriptName is
@@ -180,7 +180,7 @@ public:
* This form of the constructor loads the script in a single-statement mode,
* which prepares the query immediately and allows value binding.
*/
- KisSqlQueryLoader(const QString &scriptName, const QString &script, prepare_only_t);
+ KisSqlQueryLoader(const QString &scriptName, const QString &script, single_statement_mode_t);
~KisSqlQueryLoader();
diff --git a/libs/resources/tests/ResourceTestHelper.h b/libs/resources/tests/ResourceTestHelper.h
index 37daed69f1..336b318cef 100644
--- a/libs/resources/tests/ResourceTestHelper.h
+++ b/libs/resources/tests/ResourceTestHelper.h
@@ -251,7 +251,7 @@ bool recreateDatabaseForATest(KisResourceLocator *locator, const QString &srcLoc
KisSqlQueryLoader loader("inline://list_all_db_tables",
"SELECT name FROM sqlite_master WHERE sql IS NOT NULL and name != \"sqlite_sequence\" "
"and type = :db_resource_type",
- KisSqlQueryLoader::prepare_only);
+ KisSqlQueryLoader::single_statement_mode);
loader.query().bindValue(":db_resource_type", dbResourceType);
loader.exec();
diff --git a/libs/resources/tests/TestResourceLocator.cpp b/libs/resources/tests/TestResourceLocator.cpp
index 01ad833f09..eca038feff 100644
--- a/libs/resources/tests/TestResourceLocator.cpp
+++ b/libs/resources/tests/TestResourceLocator.cpp
@@ -163,7 +163,7 @@ int countMetaDataForResourceImpl(int resourceId, const QString &tableName)
KisSqlQueryLoader loader("inline://count_metadata_for_resource",
QString("SELECT COUNT(*) FROM metadata\n"
"WHERE foreign_id = :resource_id AND table_name = \"%1\"").arg(tableName),
- KisSqlQueryLoader::prepare_only);
+ KisSqlQueryLoader::single_statement_mode);
loader.query().bindValue(":resource_id", resourceId);
loader.exec();
@@ -194,7 +194,7 @@ int countCurrentResourcesForResourceId(int resourceId)
try {
KisSqlQueryLoader loader("inline://count_current_resource_for_resource_id",
"SELECT COUNT(*) FROM resources WHERE id = :resource_id",
- KisSqlQueryLoader::prepare_only);
+ KisSqlQueryLoader::single_statement_mode);
loader.query().bindValue(":resource_id", resourceId);
loader.exec();
@@ -215,7 +215,7 @@ int countVersionedResourcesForResourceId(int resourceId)
try {
KisSqlQueryLoader loader("inline://count_current_resource_for_resource_id",
"SELECT COUNT(*) FROM versioned_resources WHERE resource_id = :resource_id",
- KisSqlQueryLoader::prepare_only);
+ KisSqlQueryLoader::single_statement_mode);
loader.query().bindValue(":resource_id", resourceId);
loader.exec();
@@ -236,7 +236,7 @@ int countStorageRecordsForStorageId(int storageId)
try {
KisSqlQueryLoader loader("inline://count_storage_records_for_storage_id",
"SELECT COUNT(*) FROM storages WHERE id = :storage_id",
- KisSqlQueryLoader::prepare_only);
+ KisSqlQueryLoader::single_statement_mode);
loader.query().bindValue(":storage_id", storageId);
loader.exec();