diff --git a/native/cpp/CommonCpp/DatabaseManagers/NativeSQLiteConnectionManager.h b/native/cpp/CommonCpp/DatabaseManagers/NativeSQLiteConnectionManager.h --- a/native/cpp/CommonCpp/DatabaseManagers/NativeSQLiteConnectionManager.h +++ b/native/cpp/CommonCpp/DatabaseManagers/NativeSQLiteConnectionManager.h @@ -17,7 +17,7 @@ std::string encryptionKey); std::vector getAttachmentsFromLog(std::uint8_t *patchsetPtr, int patchsetSize); - void onDatabaseOpen(sqlite3 *db, std::string sqliteEncryptionKey); + void onDatabaseOpen(sqlite3 *db, std::string sqliteEncryptionKey) const; public: NativeSQLiteConnectionManager(); @@ -25,7 +25,7 @@ sqlite3 *getEphemeralConnection( std::string sqliteFilePath, - std::string sqliteEncryptionKey) override; + std::string sqliteEncryptionKey) const override; void initializeConnection( std::string sqliteFilePath, std::string sqliteEncryptionKey) override; diff --git a/native/cpp/CommonCpp/DatabaseManagers/NativeSQLiteConnectionManager.cpp b/native/cpp/CommonCpp/DatabaseManagers/NativeSQLiteConnectionManager.cpp --- a/native/cpp/CommonCpp/DatabaseManagers/NativeSQLiteConnectionManager.cpp +++ b/native/cpp/CommonCpp/DatabaseManagers/NativeSQLiteConnectionManager.cpp @@ -200,13 +200,13 @@ void NativeSQLiteConnectionManager::onDatabaseOpen( sqlite3 *db, - std::string sqliteEncryptionKey) { + std::string sqliteEncryptionKey) const { SQLiteUtils::setEncryptionKey(db, sqliteEncryptionKey); } sqlite3 *NativeSQLiteConnectionManager::getEphemeralConnection( std::string sqliteFilePath, - std::string sqliteEncryptionKey) { + std::string sqliteEncryptionKey) const { sqlite3 *db = this->createConnection(sqliteFilePath); onDatabaseOpen(db, sqliteEncryptionKey); return db; diff --git a/native/cpp/CommonCpp/DatabaseManagers/SQLiteConnectionManager.h b/native/cpp/CommonCpp/DatabaseManagers/SQLiteConnectionManager.h --- a/native/cpp/CommonCpp/DatabaseManagers/SQLiteConnectionManager.h +++ b/native/cpp/CommonCpp/DatabaseManagers/SQLiteConnectionManager.h @@ -19,7 +19,7 @@ void closeConnectionInternal(); // Shared implementation of creating a connection used by derived classes. - sqlite3 *createConnection(std::string sqliteFilePath); + sqlite3 *createConnection(std::string sqliteFilePath) const; public: SQLiteConnectionManager(); @@ -32,13 +32,13 @@ // classes. virtual sqlite3 *getEphemeralConnection( std::string sqliteFilePath, - std::string sqliteEncryptionKey) = 0; + std::string sqliteEncryptionKey) const = 0; // Creates a SQLite connection that is cached and stored as an attribute. It // can be accessed using `getConnection` and closed using `closeConnection` virtual void initializeConnection( std::string sqliteFilePath, std::string sqliteEncryptionKey) = 0; - sqlite3 *getConnection(); + sqlite3 *getConnection() const; virtual void closeConnection() = 0; virtual void validateEncryption( diff --git a/native/cpp/CommonCpp/DatabaseManagers/SQLiteConnectionManager.cpp b/native/cpp/CommonCpp/DatabaseManagers/SQLiteConnectionManager.cpp --- a/native/cpp/CommonCpp/DatabaseManagers/SQLiteConnectionManager.cpp +++ b/native/cpp/CommonCpp/DatabaseManagers/SQLiteConnectionManager.cpp @@ -11,7 +11,7 @@ SQLiteConnectionManager::SQLiteConnectionManager() : dbConnection(nullptr) { } -sqlite3 *SQLiteConnectionManager::getConnection() { +sqlite3 *SQLiteConnectionManager::getConnection() const { return dbConnection; } @@ -27,7 +27,8 @@ } } -sqlite3 *SQLiteConnectionManager::createConnection(std::string sqliteFilePath) { +sqlite3 * +SQLiteConnectionManager::createConnection(std::string sqliteFilePath) const { sqlite3 *dbConnection; int connectResult = sqlite3_open(sqliteFilePath.c_str(), &dbConnection); handleSQLiteError(connectResult, "Failed to open database connection"); diff --git a/native/cpp/CommonCpp/DatabaseManagers/WebSQLiteConnectionManager.h b/native/cpp/CommonCpp/DatabaseManagers/WebSQLiteConnectionManager.h --- a/native/cpp/CommonCpp/DatabaseManagers/WebSQLiteConnectionManager.h +++ b/native/cpp/CommonCpp/DatabaseManagers/WebSQLiteConnectionManager.h @@ -11,7 +11,7 @@ sqlite3 *getEphemeralConnection( std::string sqliteFilePath, - std::string sqliteEncryptionKey) override; + std::string sqliteEncryptionKey) const override; void initializeConnection( std::string sqliteFilePath, std::string sqliteEncryptionKey) override; diff --git a/native/cpp/CommonCpp/DatabaseManagers/WebSQLiteConnectionManager.cpp b/native/cpp/CommonCpp/DatabaseManagers/WebSQLiteConnectionManager.cpp --- a/native/cpp/CommonCpp/DatabaseManagers/WebSQLiteConnectionManager.cpp +++ b/native/cpp/CommonCpp/DatabaseManagers/WebSQLiteConnectionManager.cpp @@ -16,7 +16,7 @@ sqlite3 *WebSQLiteConnectionManager::getEphemeralConnection( std::string sqliteFilePath, - std::string sqliteEncryptionKey) { + std::string sqliteEncryptionKey) const { return this->createConnection(sqliteFilePath); // We don't want to run `PRAGMA key = ...;` // on main web database. The context is here: