<!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-&gt;EpProcessRun-&gt;search(<BR>
    &nbsp;&nbsp;&nbsp; {<BR>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'ep_config.config_name' =&gt; 'my_config',<BR>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'ep_section.section_name' =&gt; 'my_section',<BR>
    &nbsp;&nbsp;&nbsp; },<BR>
    &nbsp;&nbsp;&nbsp; {<BR>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; select =&gt; [ { max =&gt; 'me.date_created' } ],<BR>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; as&nbsp;&nbsp;&nbsp;&nbsp; =&gt; [ 'date_created' ],<BR>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'join'&nbsp;&nbsp;&nbsp;&nbsp; =&gt; {'ep_section' =&gt; ['ep_config']},<BR>
    &nbsp;&nbsp;&nbsp; }<BR>
    );<BR>
    <BR>
    say $rs-&gt;first-&gt;get_column('date_created');<BR>
    <BR>
    This works - but the date is text, whereas I was hoping it would be inflated to a&nbsp; DateTime object (as they are with regular queries). The generated SQL is<BR>
    <BR>
    SELECT MAX(me.date_created)<BR>
    FROM&nbsp;&nbsp; ep_process_run me<BR>
    JOIN&nbsp;&nbsp; ep_section ep_section<BR>
    ON&nbsp;&nbsp;&nbsp;&nbsp; ep_section.section_id = me.section_id<BR>
    JOIN&nbsp;&nbsp; ep_config ep_config<BR>
    ON&nbsp;&nbsp;&nbsp;&nbsp; ep_config.config_id = ep_section.config_id<BR>
    WHERE&nbsp; ((ep_config.config_name = ? AND ep_section.section_name = ?))<BR>
    <BR>
    I also tried<BR>
    <BR>
    my $rs = $scheduler-&gt;EpProcessRun-&gt;search(<BR>
    &nbsp;&nbsp;&nbsp; {<BR>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'ep_config.config_name' =&gt; 'my_config',<BR>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'ep_section.section_name' =&gt; 'my_section',<BR>
    &nbsp;&nbsp;&nbsp; },<BR>
    &nbsp;&nbsp;&nbsp; {<BR>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'join'&nbsp;&nbsp;&nbsp;&nbsp; =&gt; {'ep_section' =&gt; ['ep_config']},<BR>
    &nbsp;&nbsp;&nbsp; }<BR>
    );<BR>
    <BR>
    say $rs-&gt;get_column('date_created')-&gt;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>