[Dbix-class] InflateColumn::DateTime

Christopher H. Laco claco at chrislaco.com
Thu Jun 8 20:21:11 CEST 2006


Christopher H. Laco wrote:
> Mark Hedges wrote:
>> On Thu, 8 Jun 2006, Christopher H. Laco wrote:
>>> If the order item and cart item instead load InflateColumn::DateTime,
>>> all hell breaks loose. If I try copying the raw value, which is a
>>> DateTime object, I get this what trying to add to a relation:
>>>
>>>> Can't use string ("Handel::Subclassing::OrderSchema") as a HASH ref while "strict refs" in use at F:\CatInABox\extlib/DB
>>>> Ix/Class/AccessorGroup.pm line 248.
>>> If I force the copy to eval as a string, I get this error instead:
>>>
>>>> Invalid date format: 2006-06-07T00:00:00 at F:\CatInABox\extlib/DBIx/Class/InflateColumn/DateTime.pm line 57
>> That date format is the default stringification for DateTime.
>> MySQL actually seems like it can deal with it, but some DB's can't.
>>
>> Sounds like this is the case where the routine needs to
>> do something like I do here in these subrefs that I import
>> for doing inflate/deflate.  The $dt_fmt_* objects are 
>> various DateTime::Format-ish objects.
> 
> I agree. The second version/error seems kind of obvious, and I'm sure
> isn't the normal way of doing things.
> 
> It's the first version/error that's really throwing me here.
> 
> Time to start digging...
> 
> 
> -=Chris

My problem is in deflate:

>       $column =>
>         {
>           inflate => sub {
>             my ($value, $obj) = @_;
>             $obj->_datetime_parser->parse_datetime($value);
>           },
>           deflate => sub {
>             my ($value, $obj) = @_;
		$obj is not an object, just a class name during a create_related calls?
>             $obj->_datetime_parser->format_datetime($value);
>           },
>         }



Is it normal that the deflate sub get's a class name, and not an actuall
blessed object for $obj?

-=Chris

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: OpenPGP digital signature
Url : http://lists.rawmode.org/pipermail/dbix-class/attachments/20060608/deab9501/attachment.pgp 


More information about the Dbix-class mailing list