[odb-users] Problems with ODB/MySQL and boost::posix_time recording
sub-second values
Adam Walters
adam at navigatesurgical.com
Wed Jun 26 16:32:16 EDT 2013
Hi,
I am in the process of evaluating ODB and I was trying to create a simple event log table as part of that test. I was thrilled to note that MySQL has finally decided to support sub-second times in the form of TIMESTAMP(6) and DATETIME(6). After adding the appropriate pragma to my record object:
#pragma db object
class EventRecord
{
public:
EventRecord(const std::string& eventMessage, boost::posix_time::ptime localTime)
:_eventId(0), _eventMessage(eventMessage),_localTime(localTime) {}
private:
EventRecord() {}
friend class odb::access;
#pragma db id auto
unsigned long _eventId;
const std::string _eventMessage;
#pragma db type("TIMESTAMP(6)") not_null
boost::posix_time::ptime _localTime;
};
the OBD compiler dutifully spat out the correct SQL for the table:
CREATE TABLE `EventRecord` (
`eventId` BIGINT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
`eventMessage` TEXT NOT NULL,
`localTime` TIMESTAMP(6) NOT NULL)
When I run my example, however, the fractional time part for each record is stuck at zero. Is there something I am missing in the process that will enable this?
Thanks,
Adam
More information about the odb-users
mailing list