Eduard Giménez wrote:
>  
> Hi,
> 
> I'm trying to use DBIx::Class::InflateColumn to inflate some date columns,
> so I put that on the model (it's a Catalyst App attacking a MySQL DB).
> 
> __PACKAGE__->inflate_column('creation_time', {
>         inflate => sub { DateTime::Format::MySQL->parse_datetime(shift); },
>         deflate => sub { DateTime::Format::MySQL->format_datetime(shift); },
>     });

InflateColumn::DateTime is your friend. There isn't a good reason to
roll your own inflators/deflators for datetime fields.

> 
> It works well, but I have to access to this column using
> get_inflated_column("creation_time")

"have to"? Why no just use the accessor?  $obj->creation_time ?


. I would like to get the inflated
> result for each request, so doing simply a get_column("creation_time") would
> be enough.

Does not compute. get_column returns the raw DB value, not the inflated
object. If you're after the inflated object, use the accessor:
$obj->creation_time.  There's usually no good need for most people to
dive into anything other than that....esp get_inflated_column.

> 
> I couldn't find a way to do that, so now I'm trying to overload the
> inflate_result method, so it will parse each row and each column inflating
> the desired ones. 

Huh?
-=Chris

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/

Reply via email to