<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.26.3">
</HEAD>
<BODY>
<BR>
Try:<BR>
<BR>
<A HREF="http://search.cpan.org/~frew/DBIx-Class-0.08123/lib/DBIx/Class/InflateColumn/DateTime.pm">http://search.cpan.org/~frew/DBIx-Class-0.08123/lib/DBIx/Class/InflateColumn/DateTime.pm</A><BR>
<BR>
<BR>
<BR>
On Mon, 2010-09-06 at 15:58 +1200, Dan Horne wrote:<BR>
<BLOCKQUOTE TYPE=CITE>
Hi<BR>
<BR>
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:<BR>
<BR>
my $rs = $scheduler->EpProcessRun->search(<BR>
{<BR>
'ep_config.config_name' => 'my_config',<BR>
'ep_section.section_name' => 'my_section',<BR>
},<BR>
{<BR>
select => [ { max => 'me.date_created' } ],<BR>
as => [ 'date_created' ],<BR>
'join' => {'ep_section' => ['ep_config']},<BR>
}<BR>
);<BR>
<BR>
say $rs->first->get_column('date_created');<BR>
<BR>
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<BR>
<BR>
SELECT MAX(me.date_created)<BR>
FROM ep_process_run me<BR>
JOIN ep_section ep_section<BR>
ON ep_section.section_id = me.section_id<BR>
JOIN ep_config ep_config<BR>
ON ep_config.config_id = ep_section.config_id<BR>
WHERE ((ep_config.config_name = ? AND ep_section.section_name = ?))<BR>
<BR>
I also tried<BR>
<BR>
my $rs = $scheduler->EpProcessRun->search(<BR>
{<BR>
'ep_config.config_name' => 'my_config',<BR>
'ep_section.section_name' => 'my_section',<BR>
},<BR>
{<BR>
'join' => {'ep_section' => ['ep_config']},<BR>
}<BR>
);<BR>
<BR>
say $rs->get_column('date_created')->max;<BR>
<BR>
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<BR>
<BR>
Dan
<PRE>
_______________________________________________
List: <A HREF="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class">http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class</A>
IRC: irc.perl.org#dbix-class
SVN: <A HREF="http://dev.catalyst.perl.org/repos/bast/DBIx-Class/">http://dev.catalyst.perl.org/repos/bast/DBIx-Class/</A>
Searchable Archive: <A HREF="http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk">http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk</A>
</PRE>
</BLOCKQUOTE>
<TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
<TR>
<TD>
<BR>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>