Skip to content

Commit a48e978

Browse files
committed
Ido*sqlConnection#FieldToEscapedString(): don't overflow timestamps > long
1 parent b56839f commit a48e978

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/db_ido_mysql/idomysqlconnection.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -891,9 +891,9 @@ bool IdoMysqlConnection::FieldToEscapedString(const String& key, const Value& va
891891

892892
*result = static_cast<long>(dbrefcol);
893893
} else if (DbValue::IsTimestamp(value)) {
894-
long ts = rawvalue;
894+
double ts = rawvalue;
895895
std::ostringstream msgbuf;
896-
msgbuf << "FROM_UNIXTIME(" << ts << ")";
896+
msgbuf << "FROM_UNIXTIME(" << std::fixed << std::setprecision(0) << ts << ")";
897897
*result = Value(msgbuf.str());
898898
} else if (DbValue::IsObjectInsertID(value)) {
899899
auto id = static_cast<long>(rawvalue);

lib/db_ido_pgsql/idopgsqlconnection.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -700,9 +700,9 @@ bool IdoPgsqlConnection::FieldToEscapedString(const String& key, const Value& va
700700

701701
*result = static_cast<long>(dbrefcol);
702702
} else if (DbValue::IsTimestamp(value)) {
703-
long ts = rawvalue;
703+
double ts = rawvalue;
704704
std::ostringstream msgbuf;
705-
msgbuf << "TO_TIMESTAMP(" << ts << ") AT TIME ZONE 'UTC'";
705+
msgbuf << "TO_TIMESTAMP(" << std::fixed << std::setprecision(0) << ts << ") AT TIME ZONE 'UTC'";
706706
*result = Value(msgbuf.str());
707707
} else if (DbValue::IsObjectInsertID(value)) {
708708
auto id = static_cast<long>(rawvalue);

0 commit comments

Comments
 (0)