Fixed binding and extraction of DateTime for MySQL database #1897 (#1898)

This commit is contained in:
Erbengi
2017-09-22 15:15:35 +02:00
committed by Aleksandar Fabijanic
parent 238306a6ed
commit 549867dad3
4 changed files with 9 additions and 9 deletions

View File

@@ -169,7 +169,7 @@ void Binder::bind(std::size_t pos, const DateTime& val, Direction dir, const Whe
mt.hour = val.hour();
mt.minute = val.minute();
mt.second = val.second();
mt.second_part = val.millisecond();
mt.second_part = val.millisecond() * 1000 + val.microsecond();
mt.time_type = MYSQL_TIMESTAMP_DATETIME;

View File

@@ -208,7 +208,7 @@ bool Extractor::extract(std::size_t pos, DateTime& val)
if (!realExtractFixed(pos, MYSQL_TYPE_DATETIME, &mt))
return false;
val.assign(mt.year, mt.month, mt.day, mt.hour, mt.minute, mt.second, mt.second_part, 0);
val.assign(mt.year, mt.month, mt.day, mt.hour, mt.minute, mt.second, mt.second_part / 1000, mt.second_part % 1000);
return true;
}