Make changes to certain database functions and a debug assert (#804)

- Replace all interaction of std::string and sqlString.
- Add a return before a debug assertion can be triggered by lvl chunks being loaded on server start.
This commit is contained in:
Jett
2022-11-03 03:53:45 +00:00
committed by GitHub
parent 8edade5f98
commit b974eed8f5
3 changed files with 9 additions and 9 deletions

View File

@@ -35,8 +35,8 @@ void Database::Connect(const string& host, const string& database, const string&
}
void Database::Connect() {
con = driver->connect(Database::props);
con->setSchema(Database::database);
con = driver->connect(Database::props["hostName"].c_str(), Database::props["user"].c_str(), Database::props["password"].c_str());
con->setSchema(Database::database.c_str());
}
void Database::Destroy(std::string source, bool log) {

View File

@@ -45,7 +45,7 @@ void MigrationRunner::RunMigrations() {
}
stmt = Database::CreatePreppedStmt("SELECT name FROM migration_history WHERE name = ?;");
stmt->setString(1, migration.name);
stmt->setString(1, migration.name.c_str());
auto* res = stmt->executeQuery();
bool doExit = res->next();
delete res;
@@ -56,11 +56,11 @@ void MigrationRunner::RunMigrations() {
if (migration.name == "5_brick_model_sd0.sql") {
runSd0Migrations = true;
} else {
finalSQL.append(migration.data);
finalSQL.append(migration.data.c_str());
}
stmt = Database::CreatePreppedStmt("INSERT INTO migration_history (name) VALUES (?);");
stmt->setString(1, migration.name);
stmt->setString(1, migration.name.c_str());
stmt->execute();
delete stmt;
}
@@ -76,7 +76,7 @@ void MigrationRunner::RunMigrations() {
for (auto& query : migration) {
try {
if (query.empty()) continue;
simpleStatement->execute(query);
simpleStatement->execute(query.c_str());
} catch (sql::SQLException& e) {
Game::logger->Log("MigrationRunner", "Encountered error running migration: %s", e.what());
}
@@ -103,7 +103,7 @@ void MigrationRunner::RunSQLiteMigrations() {
if (migration.data.empty()) continue;
stmt = Database::CreatePreppedStmt("SELECT name FROM migration_history WHERE name = ?;");
stmt->setString(1, migration.name);
stmt->setString(1, migration.name.c_str());
auto* res = stmt->executeQuery();
bool doExit = res->next();
delete res;