[odb-users] Object creator with boost::posix_time::ptime member
: exception from boost
rkadeFR
contact at rkade.fr
Thu Jun 6 11:45:54 EDT 2013
On 06/06/2013 17:38, Boris Kolpackov wrote:
> Hi,
>
> 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.
Something I noticed: my member is a boost::posix_time::ptime
object, but the exception is about a gregorian::date. I read the code
of boost, and I assume that pTime includes a gregorian::date object.
>
>> 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.
1- I can't change the database
2- It's used as a negative infinite value :s
>
> 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.
Can I change the constructor of the object?
Or the copy?
If I understand, ODB construct an empty object with the private
cTor, and then fill the member with some copy?
Can I change the behavior of this copy to handle the exception?
> Boris
More information about the odb-users
mailing list