Ido*sqlConnection#FieldToEscapedString(): don't overflow timestamps > long

This commit is contained in:
Alexander A. Klimov 2024-05-13 16:54:38 +02:00
parent 01d3a1d382
commit ad6fcda6df
2 changed files with 4 additions and 4 deletions

View File

@ -891,9 +891,9 @@ bool IdoMysqlConnection::FieldToEscapedString(const String& key, const Value& va
*result = static_cast<long>(dbrefcol); *result = static_cast<long>(dbrefcol);
} else if (DbValue::IsTimestamp(value)) { } else if (DbValue::IsTimestamp(value)) {
long ts = rawvalue; double ts = rawvalue;
std::ostringstream msgbuf; std::ostringstream msgbuf;
msgbuf << "FROM_UNIXTIME(" << ts << ")"; msgbuf << "FROM_UNIXTIME(" << std::fixed << std::setprecision(0) << ts << ")";
*result = Value(msgbuf.str()); *result = Value(msgbuf.str());
} else if (DbValue::IsObjectInsertID(value)) { } else if (DbValue::IsObjectInsertID(value)) {
auto id = static_cast<long>(rawvalue); auto id = static_cast<long>(rawvalue);

View File

@ -700,9 +700,9 @@ bool IdoPgsqlConnection::FieldToEscapedString(const String& key, const Value& va
*result = static_cast<long>(dbrefcol); *result = static_cast<long>(dbrefcol);
} else if (DbValue::IsTimestamp(value)) { } else if (DbValue::IsTimestamp(value)) {
long ts = rawvalue; double ts = rawvalue;
std::ostringstream msgbuf; std::ostringstream msgbuf;
msgbuf << "TO_TIMESTAMP(" << ts << ") AT TIME ZONE 'UTC'"; msgbuf << "TO_TIMESTAMP(" << std::fixed << std::setprecision(0) << ts << ") AT TIME ZONE 'UTC'";
*result = Value(msgbuf.str()); *result = Value(msgbuf.str());
} else if (DbValue::IsObjectInsertID(value)) { } else if (DbValue::IsObjectInsertID(value)) {
auto id = static_cast<long>(rawvalue); auto id = static_cast<long>(rawvalue);