From add7fff92bfe494e54433ced8e90e4dddd7e5caf Mon Sep 17 00:00:00 2001 From: Relintai Date: Sat, 27 Apr 2024 14:41:42 +0200 Subject: [PATCH] DatabaseConnection::database_connect() now returns Error. --- modules/database/database_connection.cpp | 3 ++- modules/database/database_connection.h | 2 +- modules/database_sqlite/sqlite3_connection.cpp | 5 ++++- modules/database_sqlite/sqlite3_connection.h | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/database/database_connection.cpp b/modules/database/database_connection.cpp index 7390755f4..e61c50411 100644 --- a/modules/database/database_connection.cpp +++ b/modules/database/database_connection.cpp @@ -36,7 +36,8 @@ #include "query_result.h" #include "table_builder.h" -void DatabaseConnection::database_connect(const String &connection_str) { +Error DatabaseConnection::database_connect(const String &connection_str) { + return ERR_PRINTER_ON_FIRE; } Ref DatabaseConnection::query(const String &query) { diff --git a/modules/database/database_connection.h b/modules/database/database_connection.h index 3fa28a854..8445dbdf6 100644 --- a/modules/database/database_connection.h +++ b/modules/database/database_connection.h @@ -45,7 +45,7 @@ class DatabaseConnection : public Reference { GDCLASS(DatabaseConnection, Reference); public: - virtual void database_connect(const String &connection_str); + virtual Error database_connect(const String &connection_str); virtual Ref query(const String &query); virtual void query_run(const String &query); diff --git a/modules/database_sqlite/sqlite3_connection.cpp b/modules/database_sqlite/sqlite3_connection.cpp index 80530e7bf..f1e209e4b 100644 --- a/modules/database_sqlite/sqlite3_connection.cpp +++ b/modules/database_sqlite/sqlite3_connection.cpp @@ -26,7 +26,7 @@ Ref SQLite3DatabaseConnection::get_table_builder() { return b; } -void SQLite3DatabaseConnection::database_connect(const String &connection_str) { +Error SQLite3DatabaseConnection::database_connect(const String &connection_str) { int ret = sqlite3_config(SQLITE_CONFIG_SERIALIZED); //if (ret != SQLITE_OK) { //ERR_PRINT("SQLITE3 multithreading is not supported!\n"); @@ -39,7 +39,10 @@ void SQLite3DatabaseConnection::database_connect(const String &connection_str) { if (ret != SQLITE_OK) { ERR_PRINT(vformat("SQLITE3 database_connect failed! code: %d !", ret)); + return FAILED; } + + return OK; } Ref SQLite3DatabaseConnection::query(const String &query) { diff --git a/modules/database_sqlite/sqlite3_connection.h b/modules/database_sqlite/sqlite3_connection.h index b412aac40..c00a4274d 100644 --- a/modules/database_sqlite/sqlite3_connection.h +++ b/modules/database_sqlite/sqlite3_connection.h @@ -13,7 +13,7 @@ struct sqlite3; class SQLite3DatabaseConnection : public DatabaseConnection { public: - void database_connect(const String &connection_str); + Error database_connect(const String &connection_str); Ref query(const String &query); void query_run(const String &query);