[Dbix-class] Date not inflating

Neil Lunn neil.lunn at trixan.com
Mon Sep 6 04:16:44 GMT 2010


Try:

http://search.cpan.org/~frew/DBIx-Class-0.08123/lib/DBIx/Class/InflateColumn/DateTime.pm



On Mon, 2010-09-06 at 15:58 +1200, Dan Horne wrote:

> Hi
> 
> Consider the following: A config has many sections. A section has many
> process runs. I want to find the latest process run from a config and
> section combination:
> 
> my $rs = $scheduler->EpProcessRun->search(
>     {
>         'ep_config.config_name' => 'my_config',
>         'ep_section.section_name' => 'my_section',
>     },
>     {
>         select => [ { max => 'me.date_created' } ],
>         as     => [ 'date_created' ],
>         'join'     => {'ep_section' => ['ep_config']},
>     }
> );
> 
> say $rs->first->get_column('date_created');
> 
> This works - but the date is text, whereas I was hoping it would be
> inflated to a  DateTime object (as they are with regular queries). The
> generated SQL is
> 
> SELECT MAX(me.date_created)
> FROM   ep_process_run me
> JOIN   ep_section ep_section
> ON     ep_section.section_id = me.section_id
> JOIN   ep_config ep_config
> ON     ep_config.config_id = ep_section.config_id
> WHERE  ((ep_config.config_name = ? AND ep_section.section_name = ?))
> 
> I also tried
> 
> my $rs = $scheduler->EpProcessRun->search(
>     {
>         'ep_config.config_name' => 'my_config',
>         'ep_section.section_name' => 'my_section',
>     },
>     {
>         'join'     => {'ep_section' => ['ep_config']},
>     }
> );
> 
> say $rs->get_column('date_created')->max;
> 
> The generated SQL is exactly the same, and the date isn't inflated. Am
> I doing something wrong, or have I hit a DBIx::Class limitation? I;m
> on DBIx:Class v0.08123 on Win32
> 
> Dan
> 
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20100906/da8db454/attachment.htm


More information about the DBIx-Class mailing list