diff --git a/src/libs/database/impl/Db.hpp b/src/libs/database/impl/Db.hpp index 60002d26..98299b0e 100644 --- a/src/libs/database/impl/Db.hpp +++ b/src/libs/database/impl/Db.hpp @@ -20,6 +20,7 @@ #pragma once #include +#include #include #include @@ -37,7 +38,7 @@ namespace lms::db Session& getTLSSession() override; - void executeSql(const std::string& sql) override; + void executeSql(const std::string& sql); private: Db(const Db&) = delete; diff --git a/src/libs/database/impl/Migration.cpp b/src/libs/database/impl/Migration.cpp index d6664c87..194d1500 100644 --- a/src/libs/database/impl/Migration.cpp +++ b/src/libs/database/impl/Migration.cpp @@ -67,7 +67,7 @@ namespace lms::db::Migration class ScopedNoForeignKeys { public: - ScopedNoForeignKeys(IDb& db) + ScopedNoForeignKeys(Db& db) : _db{ db } { _db.executeSql("PRAGMA foreign_keys=OFF"); @@ -83,7 +83,7 @@ namespace lms::db::Migration ScopedNoForeignKeys& operator=(const ScopedNoForeignKeys&) = delete; ScopedNoForeignKeys& operator=(ScopedNoForeignKeys&&) = delete; - IDb& _db; + Db& _db; }; namespace @@ -1422,7 +1422,7 @@ WHERE art.image_id IS NULL)"); { constexpr std::string_view outdatedMsg{ "Outdated database, please rebuild it (delete the .db file and restart)" }; - ScopedNoForeignKeys noPragmaKeys{ session.getDb() }; + ScopedNoForeignKeys noPragmaKeys{ static_cast(session.getDb()) }; using MigrationFunction = std::function; diff --git a/src/libs/database/impl/Session.cpp b/src/libs/database/impl/Session.cpp index 3ebcebc7..4d7475be 100644 --- a/src/libs/database/impl/Session.cpp +++ b/src/libs/database/impl/Session.cpp @@ -360,7 +360,7 @@ namespace lms::db // We manually take a lock here since vacuum cannot be inside a transaction { std::unique_lock lock{ static_cast(_db).getMutex() }; - _db.executeSql("VACUUM"); + static_cast(_db).executeSql("VACUUM"); } LMS_LOG(DB, INFO, "Vacuum complete!"); diff --git a/src/libs/database/include/database/IDb.hpp b/src/libs/database/include/database/IDb.hpp index 1823275a..aa332f34 100644 --- a/src/libs/database/include/database/IDb.hpp +++ b/src/libs/database/include/database/IDb.hpp @@ -31,8 +31,6 @@ namespace lms::db virtual ~IDb() = default; virtual Session& getTLSSession() = 0; - - virtual void executeSql(const std::string& sql) = 0; // TODO make this private }; std::unique_ptr createDb(const std::filesystem::path& dbPath, std::size_t connectionCount = 10);