added test for date and time, sql read and write functionality

This commit is contained in:
2026-01-06 22:23:50 +01:00
parent 0c6b5a0a93
commit c48bd4f9d6
17 changed files with 516 additions and 360 deletions
@@ -123,15 +123,23 @@ void postgres_parameter_binder::write_value(const size_t pos, const std::string
write_value(pos, x);
}
void postgres_parameter_binder::write_value(const size_t pos, const utils::date_type_t &/*x*/) {
// bind_data_.strings[pos] = utils::to_string(x, utils::date_format::ISO8601);
void postgres_parameter_binder::write_value(const size_t pos, const utils::date_type_t &x) {
char buf[11]; // "YYYY-MM-DD" + '\0'
std::snprintf(buf, sizeof(buf), "%04d-%02u-%02u", x.year, static_cast<unsigned>(x.month), static_cast<unsigned>(x.day));
bind_data_.strings[pos] = std::string{buf};
bind_data_.values[pos] = bind_data_.strings[pos].data();
bind_data_.lengths[pos] = static_cast<int>(bind_data_.strings[pos].size());
bind_data_.formats[pos] = 0;
}
void postgres_parameter_binder::write_value(const size_t pos, const utils::time_type_t &/*x*/) {
// bind_data_.strings[pos] = utils::to_string(x, "%Y-%m-%d %T.%f");
void postgres_parameter_binder::write_value(const size_t pos, const utils::time_type_t &x) {
char buf[16]; // "HH:MM:SS.ffffff" + '\0'
std::snprintf(buf, sizeof(buf), "%02u:%02u:%02u.%06u",
static_cast<unsigned>(x.hour), static_cast<unsigned>(x.minute), static_cast<unsigned>(x.second), x.microsecond);
bind_data_.strings[pos] = std::string{buf};
bind_data_.values[pos] = bind_data_.strings[pos].data();
bind_data_.lengths[pos] = static_cast<int>(bind_data_.strings[pos].size());
bind_data_.formats[pos] = 0;