mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-27 16:37: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_FACTION_ASSOCIATION_REPOSITORY_H
|
||||
@@ -184,8 +184,9 @@ public:
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} WHERE id = {} LIMIT 1",
|
||||
"{} WHERE {} = {} LIMIT 1",
|
||||
BaseSelect(),
|
||||
PrimaryKey(),
|
||||
faction_association_id
|
||||
)
|
||||
);
|
||||
@@ -196,25 +197,25 @@ public:
|
||||
|
||||
e.id = static_cast<int32_t>(atoi(row[0]));
|
||||
e.id_1 = static_cast<int32_t>(atoi(row[1]));
|
||||
e.mod_1 = strtof(row[2], nullptr);
|
||||
e.mod_1 = row[2] ? strtof(row[2], nullptr) : 0;
|
||||
e.id_2 = static_cast<int32_t>(atoi(row[3]));
|
||||
e.mod_2 = strtof(row[4], nullptr);
|
||||
e.mod_2 = row[4] ? strtof(row[4], nullptr) : 0;
|
||||
e.id_3 = static_cast<int32_t>(atoi(row[5]));
|
||||
e.mod_3 = strtof(row[6], nullptr);
|
||||
e.mod_3 = row[6] ? strtof(row[6], nullptr) : 0;
|
||||
e.id_4 = static_cast<int32_t>(atoi(row[7]));
|
||||
e.mod_4 = strtof(row[8], nullptr);
|
||||
e.mod_4 = row[8] ? strtof(row[8], nullptr) : 0;
|
||||
e.id_5 = static_cast<int32_t>(atoi(row[9]));
|
||||
e.mod_5 = strtof(row[10], nullptr);
|
||||
e.mod_5 = row[10] ? strtof(row[10], nullptr) : 0;
|
||||
e.id_6 = static_cast<int32_t>(atoi(row[11]));
|
||||
e.mod_6 = strtof(row[12], nullptr);
|
||||
e.mod_6 = row[12] ? strtof(row[12], nullptr) : 0;
|
||||
e.id_7 = static_cast<int32_t>(atoi(row[13]));
|
||||
e.mod_7 = strtof(row[14], nullptr);
|
||||
e.mod_7 = row[14] ? strtof(row[14], nullptr) : 0;
|
||||
e.id_8 = static_cast<int32_t>(atoi(row[15]));
|
||||
e.mod_8 = strtof(row[16], nullptr);
|
||||
e.mod_8 = row[16] ? strtof(row[16], nullptr) : 0;
|
||||
e.id_9 = static_cast<int32_t>(atoi(row[17]));
|
||||
e.mod_9 = strtof(row[18], nullptr);
|
||||
e.mod_9 = row[18] ? strtof(row[18], nullptr) : 0;
|
||||
e.id_10 = static_cast<int32_t>(atoi(row[19]));
|
||||
e.mod_10 = strtof(row[20], nullptr);
|
||||
e.mod_10 = row[20] ? strtof(row[20], nullptr) : 0;
|
||||
|
||||
return e;
|
||||
}
|
||||
@@ -396,25 +397,25 @@ public:
|
||||
|
||||
e.id = static_cast<int32_t>(atoi(row[0]));
|
||||
e.id_1 = static_cast<int32_t>(atoi(row[1]));
|
||||
e.mod_1 = strtof(row[2], nullptr);
|
||||
e.mod_1 = row[2] ? strtof(row[2], nullptr) : 0;
|
||||
e.id_2 = static_cast<int32_t>(atoi(row[3]));
|
||||
e.mod_2 = strtof(row[4], nullptr);
|
||||
e.mod_2 = row[4] ? strtof(row[4], nullptr) : 0;
|
||||
e.id_3 = static_cast<int32_t>(atoi(row[5]));
|
||||
e.mod_3 = strtof(row[6], nullptr);
|
||||
e.mod_3 = row[6] ? strtof(row[6], nullptr) : 0;
|
||||
e.id_4 = static_cast<int32_t>(atoi(row[7]));
|
||||
e.mod_4 = strtof(row[8], nullptr);
|
||||
e.mod_4 = row[8] ? strtof(row[8], nullptr) : 0;
|
||||
e.id_5 = static_cast<int32_t>(atoi(row[9]));
|
||||
e.mod_5 = strtof(row[10], nullptr);
|
||||
e.mod_5 = row[10] ? strtof(row[10], nullptr) : 0;
|
||||
e.id_6 = static_cast<int32_t>(atoi(row[11]));
|
||||
e.mod_6 = strtof(row[12], nullptr);
|
||||
e.mod_6 = row[12] ? strtof(row[12], nullptr) : 0;
|
||||
e.id_7 = static_cast<int32_t>(atoi(row[13]));
|
||||
e.mod_7 = strtof(row[14], nullptr);
|
||||
e.mod_7 = row[14] ? strtof(row[14], nullptr) : 0;
|
||||
e.id_8 = static_cast<int32_t>(atoi(row[15]));
|
||||
e.mod_8 = strtof(row[16], nullptr);
|
||||
e.mod_8 = row[16] ? strtof(row[16], nullptr) : 0;
|
||||
e.id_9 = static_cast<int32_t>(atoi(row[17]));
|
||||
e.mod_9 = strtof(row[18], nullptr);
|
||||
e.mod_9 = row[18] ? strtof(row[18], nullptr) : 0;
|
||||
e.id_10 = static_cast<int32_t>(atoi(row[19]));
|
||||
e.mod_10 = strtof(row[20], nullptr);
|
||||
e.mod_10 = row[20] ? strtof(row[20], nullptr) : 0;
|
||||
|
||||
all_entries.push_back(e);
|
||||
}
|
||||
@@ -441,25 +442,25 @@ public:
|
||||
|
||||
e.id = static_cast<int32_t>(atoi(row[0]));
|
||||
e.id_1 = static_cast<int32_t>(atoi(row[1]));
|
||||
e.mod_1 = strtof(row[2], nullptr);
|
||||
e.mod_1 = row[2] ? strtof(row[2], nullptr) : 0;
|
||||
e.id_2 = static_cast<int32_t>(atoi(row[3]));
|
||||
e.mod_2 = strtof(row[4], nullptr);
|
||||
e.mod_2 = row[4] ? strtof(row[4], nullptr) : 0;
|
||||
e.id_3 = static_cast<int32_t>(atoi(row[5]));
|
||||
e.mod_3 = strtof(row[6], nullptr);
|
||||
e.mod_3 = row[6] ? strtof(row[6], nullptr) : 0;
|
||||
e.id_4 = static_cast<int32_t>(atoi(row[7]));
|
||||
e.mod_4 = strtof(row[8], nullptr);
|
||||
e.mod_4 = row[8] ? strtof(row[8], nullptr) : 0;
|
||||
e.id_5 = static_cast<int32_t>(atoi(row[9]));
|
||||
e.mod_5 = strtof(row[10], nullptr);
|
||||
e.mod_5 = row[10] ? strtof(row[10], nullptr) : 0;
|
||||
e.id_6 = static_cast<int32_t>(atoi(row[11]));
|
||||
e.mod_6 = strtof(row[12], nullptr);
|
||||
e.mod_6 = row[12] ? strtof(row[12], nullptr) : 0;
|
||||
e.id_7 = static_cast<int32_t>(atoi(row[13]));
|
||||
e.mod_7 = strtof(row[14], nullptr);
|
||||
e.mod_7 = row[14] ? strtof(row[14], nullptr) : 0;
|
||||
e.id_8 = static_cast<int32_t>(atoi(row[15]));
|
||||
e.mod_8 = strtof(row[16], nullptr);
|
||||
e.mod_8 = row[16] ? strtof(row[16], nullptr) : 0;
|
||||
e.id_9 = static_cast<int32_t>(atoi(row[17]));
|
||||
e.mod_9 = strtof(row[18], nullptr);
|
||||
e.mod_9 = row[18] ? strtof(row[18], nullptr) : 0;
|
||||
e.id_10 = static_cast<int32_t>(atoi(row[19]));
|
||||
e.mod_10 = strtof(row[20], nullptr);
|
||||
e.mod_10 = row[20] ? strtof(row[20], nullptr) : 0;
|
||||
|
||||
all_entries.push_back(e);
|
||||
}
|
||||
@@ -518,6 +519,102 @@ 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 FactionAssociation &e
|
||||
)
|
||||
{
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.id));
|
||||
v.push_back(std::to_string(e.id_1));
|
||||
v.push_back(std::to_string(e.mod_1));
|
||||
v.push_back(std::to_string(e.id_2));
|
||||
v.push_back(std::to_string(e.mod_2));
|
||||
v.push_back(std::to_string(e.id_3));
|
||||
v.push_back(std::to_string(e.mod_3));
|
||||
v.push_back(std::to_string(e.id_4));
|
||||
v.push_back(std::to_string(e.mod_4));
|
||||
v.push_back(std::to_string(e.id_5));
|
||||
v.push_back(std::to_string(e.mod_5));
|
||||
v.push_back(std::to_string(e.id_6));
|
||||
v.push_back(std::to_string(e.mod_6));
|
||||
v.push_back(std::to_string(e.id_7));
|
||||
v.push_back(std::to_string(e.mod_7));
|
||||
v.push_back(std::to_string(e.id_8));
|
||||
v.push_back(std::to_string(e.mod_8));
|
||||
v.push_back(std::to_string(e.id_9));
|
||||
v.push_back(std::to_string(e.mod_9));
|
||||
v.push_back(std::to_string(e.id_10));
|
||||
v.push_back(std::to_string(e.mod_10));
|
||||
|
||||
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<FactionAssociation> &entries
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_chunks;
|
||||
|
||||
for (auto &e: entries) {
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.id));
|
||||
v.push_back(std::to_string(e.id_1));
|
||||
v.push_back(std::to_string(e.mod_1));
|
||||
v.push_back(std::to_string(e.id_2));
|
||||
v.push_back(std::to_string(e.mod_2));
|
||||
v.push_back(std::to_string(e.id_3));
|
||||
v.push_back(std::to_string(e.mod_3));
|
||||
v.push_back(std::to_string(e.id_4));
|
||||
v.push_back(std::to_string(e.mod_4));
|
||||
v.push_back(std::to_string(e.id_5));
|
||||
v.push_back(std::to_string(e.mod_5));
|
||||
v.push_back(std::to_string(e.id_6));
|
||||
v.push_back(std::to_string(e.mod_6));
|
||||
v.push_back(std::to_string(e.id_7));
|
||||
v.push_back(std::to_string(e.mod_7));
|
||||
v.push_back(std::to_string(e.id_8));
|
||||
v.push_back(std::to_string(e.mod_8));
|
||||
v.push_back(std::to_string(e.id_9));
|
||||
v.push_back(std::to_string(e.mod_9));
|
||||
v.push_back(std::to_string(e.id_10));
|
||||
v.push_back(std::to_string(e.mod_10));
|
||||
|
||||
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_FACTION_ASSOCIATION_REPOSITORY_H
|
||||
|
||||
Reference in New Issue
Block a user