[Dbix-class] Date not inflating
Dan Horne
dan.horne at redbone.co.nz
Mon Sep 6 03:58:01 GMT 2010
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20100906/b64=
6bf4b/attachment.htm
More information about the DBIx-Class
mailing list