1
0
mirror of https://github.com/anope/anope.git synced 2026-06-26 14:16:39 +02:00

Bug #1445 - Empty out columns in SQL we have no data for on

insert. This is caused from serialize() only setting a key on
certain conditions and otherwise doing nothing at all.
This commit is contained in:
Adam
2012-09-30 20:26:40 -04:00
parent 56df1abdd8
commit ad37bc9639
5 changed files with 19 additions and 7 deletions
+8 -2
View File
@@ -48,7 +48,7 @@ class SQLiteService : public SQLProvider
std::vector<SQLQuery> CreateTable(const Anope::string &table, const Serialize::Data &data) anope_override;
SQLQuery BuildInsert(const Anope::string &table, unsigned int id, const Serialize::Data &data);
SQLQuery BuildInsert(const Anope::string &table, unsigned int id, Serialize::Data &data);
SQLQuery GetTables(const Anope::string &prefix);
@@ -253,8 +253,14 @@ std::vector<SQLQuery> SQLiteService::CreateTable(const Anope::string &table, con
return queries;
}
SQLQuery SQLiteService::BuildInsert(const Anope::string &table, unsigned int id, const Serialize::Data &data)
SQLQuery SQLiteService::BuildInsert(const Anope::string &table, unsigned int id, Serialize::Data &data)
{
/* Empty columns not present in the data set */
const std::set<Anope::string> &known_cols = this->active_schema[table];
for (std::set<Anope::string>::iterator it = known_cols.begin(), it_end = known_cols.end(); it != it_end; ++it)
if (*it != "id" && data.count(*it) == 0)
data[*it] << "";
Anope::string query_text = "REPLACE INTO `" + table + "` (";
if (id > 0)
query_text += "`id`,";