[odb-users] Object creator with boost::posix_time::ptime member : exception from boost

Boris Kolpackov boris at codesynthesis.com
Thu Jun 6 11:38:48 EDT 2013


rkadeFR <contact at rkade.fr> writes:

> I have some "0000-00-00 00:00:00" datetime in my DB (I can't change that).
> So i put lots of log, and I can only see the private constructor
> called, and then... nothing except my exception.
> Can you explain me the way the iterator works?

The actual object loading happens when you dereference the iterator.
What probably happens in your case is ODB is trying to load one of
the objects with the "0000-00-00 00:00:00" value and since it is
not valid for Boost ptime, an exception is thrown.

> And the work around I need to implement in order to avoid the
> exception ?

The easiest would be to change your database to represent invalid
datetimes (that's what I assume "0000-00-00 00:00:00" are used for)
as NULL values. ODB will then map such NULL values to the special
not_a_date_time value -- nice and clean.

The alternative would be for us to add extra code to ODB in order
to recognize all-zero datetime values and treat them as NULL.


More information about the odb-users mailing list