[Bug Fix] Fix Instance Repository (#2598)

Instance code used to use a `REPLACE INTO`, add an extended repository method to do this so we're not getting `DUPLICATE` errors.
This commit is contained in:
Alex King
2022-11-30 21:31:39 -05:00
committed by GitHub
parent ecc34940b4
commit 85ae36ede5
2 changed files with 40 additions and 25 deletions
@@ -73,6 +73,27 @@ public:
return (results.Success() ? results.RowsAffected() : 0);
}
static bool ReplaceOne(Database& db, InstanceListPlayer e)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.charid));
auto results = db.QueryDatabase(
fmt::format(
"REPLACE INTO {} VALUES ({})",
TableName(),
Strings::Implode(",", v)
)
);
if (results.Success()) {
return true;
}
return false;
}
};
#endif //EQEMU_INSTANCE_LIST_PLAYER_REPOSITORY_H