[Repositories] Fix datetime zero-value save behavior (#3976)

This commit is contained in:
Chris Miles
2024-01-14 00:10:13 -06:00
committed by GitHub
parent e40267b9b8
commit 14509fcc4e
133 changed files with 3647 additions and 3658 deletions
@@ -136,11 +136,11 @@ public:
SharedTasks e{};
e.id = row[0] ? strtoll(row[0], nullptr, 10) : 0;
e.task_id = static_cast<int32_t>(atoi(row[1]));
e.task_id = row[1] ? static_cast<int32_t>(atoi(row[1])) : 0;
e.accepted_time = strtoll(row[2] ? row[2] : "-1", nullptr, 10);
e.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
e.completion_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
e.is_locked = static_cast<int8_t>(atoi(row[5]));
e.is_locked = row[5] ? static_cast<int8_t>(atoi(row[5])) : 0;
return e;
}
@@ -175,9 +175,9 @@ public:
auto columns = Columns();
v.push_back(columns[1] + " = " + std::to_string(e.task_id));
v.push_back(columns[2] + " = FROM_UNIXTIME(" + (e.accepted_time > 0 ? std::to_string(e.accepted_time) : "null") + ")");
v.push_back(columns[3] + " = FROM_UNIXTIME(" + (e.expire_time > 0 ? std::to_string(e.expire_time) : "null") + ")");
v.push_back(columns[4] + " = FROM_UNIXTIME(" + (e.completion_time > 0 ? std::to_string(e.completion_time) : "null") + ")");
v.push_back(columns[2] + " = FROM_UNIXTIME(" + (e.accepted_time > 0 ? std::to_string(e.accepted_time) : "UNIX_TIMESTAMP()") + ")");
v.push_back(columns[3] + " = FROM_UNIXTIME(" + (e.expire_time > 0 ? std::to_string(e.expire_time) : "UNIX_TIMESTAMP()") + ")");
v.push_back(columns[4] + " = FROM_UNIXTIME(" + (e.completion_time > 0 ? std::to_string(e.completion_time) : "UNIX_TIMESTAMP()") + ")");
v.push_back(columns[5] + " = " + std::to_string(e.is_locked));
auto results = db.QueryDatabase(
@@ -202,9 +202,9 @@ public:
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.task_id));
v.push_back("FROM_UNIXTIME(" + (e.accepted_time > 0 ? std::to_string(e.accepted_time) : "null") + ")");
v.push_back("FROM_UNIXTIME(" + (e.expire_time > 0 ? std::to_string(e.expire_time) : "null") + ")");
v.push_back("FROM_UNIXTIME(" + (e.completion_time > 0 ? std::to_string(e.completion_time) : "null") + ")");
v.push_back("FROM_UNIXTIME(" + (e.accepted_time > 0 ? std::to_string(e.accepted_time) : "UNIX_TIMESTAMP()") + ")");
v.push_back("FROM_UNIXTIME(" + (e.expire_time > 0 ? std::to_string(e.expire_time) : "UNIX_TIMESTAMP()") + ")");
v.push_back("FROM_UNIXTIME(" + (e.completion_time > 0 ? std::to_string(e.completion_time) : "UNIX_TIMESTAMP()") + ")");
v.push_back(std::to_string(e.is_locked));
auto results = db.QueryDatabase(
@@ -237,9 +237,9 @@ public:
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.task_id));
v.push_back("FROM_UNIXTIME(" + (e.accepted_time > 0 ? std::to_string(e.accepted_time) : "null") + ")");
v.push_back("FROM_UNIXTIME(" + (e.expire_time > 0 ? std::to_string(e.expire_time) : "null") + ")");
v.push_back("FROM_UNIXTIME(" + (e.completion_time > 0 ? std::to_string(e.completion_time) : "null") + ")");
v.push_back("FROM_UNIXTIME(" + (e.accepted_time > 0 ? std::to_string(e.accepted_time) : "UNIX_TIMESTAMP()") + ")");
v.push_back("FROM_UNIXTIME(" + (e.expire_time > 0 ? std::to_string(e.expire_time) : "UNIX_TIMESTAMP()") + ")");
v.push_back("FROM_UNIXTIME(" + (e.completion_time > 0 ? std::to_string(e.completion_time) : "UNIX_TIMESTAMP()") + ")");
v.push_back(std::to_string(e.is_locked));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
@@ -275,11 +275,11 @@ public:
SharedTasks e{};
e.id = row[0] ? strtoll(row[0], nullptr, 10) : 0;
e.task_id = static_cast<int32_t>(atoi(row[1]));
e.task_id = row[1] ? static_cast<int32_t>(atoi(row[1])) : 0;
e.accepted_time = strtoll(row[2] ? row[2] : "-1", nullptr, 10);
e.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
e.completion_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
e.is_locked = static_cast<int8_t>(atoi(row[5]));
e.is_locked = row[5] ? static_cast<int8_t>(atoi(row[5])) : 0;
all_entries.push_back(e);
}
@@ -305,11 +305,11 @@ public:
SharedTasks e{};
e.id = row[0] ? strtoll(row[0], nullptr, 10) : 0;
e.task_id = static_cast<int32_t>(atoi(row[1]));
e.task_id = row[1] ? static_cast<int32_t>(atoi(row[1])) : 0;
e.accepted_time = strtoll(row[2] ? row[2] : "-1", nullptr, 10);
e.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
e.completion_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
e.is_locked = static_cast<int8_t>(atoi(row[5]));
e.is_locked = row[5] ? static_cast<int8_t>(atoi(row[5])) : 0;
all_entries.push_back(e);
}
@@ -386,9 +386,9 @@ public:
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.task_id));
v.push_back("FROM_UNIXTIME(" + (e.accepted_time > 0 ? std::to_string(e.accepted_time) : "null") + ")");
v.push_back("FROM_UNIXTIME(" + (e.expire_time > 0 ? std::to_string(e.expire_time) : "null") + ")");
v.push_back("FROM_UNIXTIME(" + (e.completion_time > 0 ? std::to_string(e.completion_time) : "null") + ")");
v.push_back("FROM_UNIXTIME(" + (e.accepted_time > 0 ? std::to_string(e.accepted_time) : "UNIX_TIMESTAMP()") + ")");
v.push_back("FROM_UNIXTIME(" + (e.expire_time > 0 ? std::to_string(e.expire_time) : "UNIX_TIMESTAMP()") + ")");
v.push_back("FROM_UNIXTIME(" + (e.completion_time > 0 ? std::to_string(e.completion_time) : "UNIX_TIMESTAMP()") + ")");
v.push_back(std::to_string(e.is_locked));
auto results = db.QueryDatabase(
@@ -414,9 +414,9 @@ public:
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.task_id));
v.push_back("FROM_UNIXTIME(" + (e.accepted_time > 0 ? std::to_string(e.accepted_time) : "null") + ")");
v.push_back("FROM_UNIXTIME(" + (e.expire_time > 0 ? std::to_string(e.expire_time) : "null") + ")");
v.push_back("FROM_UNIXTIME(" + (e.completion_time > 0 ? std::to_string(e.completion_time) : "null") + ")");
v.push_back("FROM_UNIXTIME(" + (e.accepted_time > 0 ? std::to_string(e.accepted_time) : "UNIX_TIMESTAMP()") + ")");
v.push_back("FROM_UNIXTIME(" + (e.expire_time > 0 ? std::to_string(e.expire_time) : "UNIX_TIMESTAMP()") + ")");
v.push_back("FROM_UNIXTIME(" + (e.completion_time > 0 ? std::to_string(e.completion_time) : "UNIX_TIMESTAMP()") + ")");
v.push_back(std::to_string(e.is_locked));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");