[Dbix-class] Date not inflating

Dan Horne dan.horne at redbone.co.nz
Mon Sep 6 04:31:43 GMT 2010


Hi

Which part of the documentation are you referring to? My dates normally
inflate, but not when I apply the max function.

On 6 September 2010 16:16, Neil Lunn <neil.lunn at trixan.com> wrote:

>
> Try:
>
>
> http://search.cpan.org/~frew/DBIx-Class-0.08123/lib/DBIx/Class/InflateCol=
umn/DateTime.pm<http://search.cpan.org/%7Efrew/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 =3D $scheduler->EpProcessRun->search(
>     {
>         'ep_config.config_name' =3D> 'my_config',
>         'ep_section.section_name' =3D> 'my_section',
>     },
>     {
>         select =3D> [ { max =3D> 'me.date_created' } ],
>         as     =3D> [ 'date_created' ],
>         'join'     =3D> {'ep_section' =3D> ['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 =3D me.section_id
> JOIN   ep_config ep_config
> ON     ep_config.config_id =3D ep_section.config_id
> WHERE  ((ep_config.config_name =3D ? AND ep_section.section_name =3D ?))
>
> I also tried
>
> my $rs =3D $scheduler->EpProcessRun->search(
>     {
>         'ep_config.config_name' =3D> 'my_config',
>         'ep_section.section_name' =3D> 'my_section',
>     },
>     {
>         'join'     =3D> {'ep_section' =3D> ['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
>
>
>
> _______________________________________________
> 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/551=
36bf2/attachment.htm


More information about the DBIx-Class mailing list