mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-26 23:57:17 +00:00
[Repository] Add null integer column support, instance_list notes migration, regenerate repositories (#3969)
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
* Any modifications to base repositories are to be made by the generator only
|
||||
*
|
||||
* @generator ./utils/scripts/generators/repository-generator.pl
|
||||
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
|
||||
* @docs https://docs.eqemu.io/developer/repositories
|
||||
*/
|
||||
|
||||
#ifndef EQEMU_BASE_TIMERS_REPOSITORY_H
|
||||
@@ -120,8 +120,9 @@ public:
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} WHERE id = {} LIMIT 1",
|
||||
"{} WHERE {} = {} LIMIT 1",
|
||||
BaseSelect(),
|
||||
PrimaryKey(),
|
||||
timers_id
|
||||
)
|
||||
);
|
||||
@@ -131,9 +132,9 @@ public:
|
||||
Timers e{};
|
||||
|
||||
e.char_id = static_cast<int32_t>(atoi(row[0]));
|
||||
e.type = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||
e.start = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
|
||||
e.duration = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
|
||||
e.type = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
|
||||
e.start = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
|
||||
e.duration = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
|
||||
e.enable = static_cast<int8_t>(atoi(row[4]));
|
||||
|
||||
return e;
|
||||
@@ -267,9 +268,9 @@ public:
|
||||
Timers e{};
|
||||
|
||||
e.char_id = static_cast<int32_t>(atoi(row[0]));
|
||||
e.type = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||
e.start = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
|
||||
e.duration = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
|
||||
e.type = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
|
||||
e.start = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
|
||||
e.duration = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
|
||||
e.enable = static_cast<int8_t>(atoi(row[4]));
|
||||
|
||||
all_entries.push_back(e);
|
||||
@@ -296,9 +297,9 @@ public:
|
||||
Timers e{};
|
||||
|
||||
e.char_id = static_cast<int32_t>(atoi(row[0]));
|
||||
e.type = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||
e.start = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
|
||||
e.duration = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
|
||||
e.type = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
|
||||
e.start = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
|
||||
e.duration = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
|
||||
e.enable = static_cast<int8_t>(atoi(row[4]));
|
||||
|
||||
all_entries.push_back(e);
|
||||
@@ -358,6 +359,70 @@ public:
|
||||
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
|
||||
}
|
||||
|
||||
static std::string BaseReplace()
|
||||
{
|
||||
return fmt::format(
|
||||
"REPLACE INTO {} ({}) ",
|
||||
TableName(),
|
||||
ColumnsRaw()
|
||||
);
|
||||
}
|
||||
|
||||
static int ReplaceOne(
|
||||
Database& db,
|
||||
const Timers &e
|
||||
)
|
||||
{
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.char_id));
|
||||
v.push_back(std::to_string(e.type));
|
||||
v.push_back(std::to_string(e.start));
|
||||
v.push_back(std::to_string(e.duration));
|
||||
v.push_back(std::to_string(e.enable));
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} VALUES ({})",
|
||||
BaseReplace(),
|
||||
Strings::Implode(",", v)
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static int ReplaceMany(
|
||||
Database& db,
|
||||
const std::vector<Timers> &entries
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_chunks;
|
||||
|
||||
for (auto &e: entries) {
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.char_id));
|
||||
v.push_back(std::to_string(e.type));
|
||||
v.push_back(std::to_string(e.start));
|
||||
v.push_back(std::to_string(e.duration));
|
||||
v.push_back(std::to_string(e.enable));
|
||||
|
||||
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
|
||||
}
|
||||
|
||||
std::vector<std::string> v;
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} VALUES {}",
|
||||
BaseReplace(),
|
||||
Strings::Implode(",", insert_chunks)
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
};
|
||||
|
||||
#endif //EQEMU_BASE_TIMERS_REPOSITORY_H
|
||||
|
||||
Reference in New Issue
Block a user