[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 authored and GitHub committed 2022-11-30 21:31:39 -05:00
1 parent ecc34940b4
commit 85ae36ede5
2 files changed
+40 -25

No files matched your search

@@ -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