Was pointing out that a a Inflator is a convenience method from the
original object.

In your query source:

select => [ { max => 'me.date_created' } ],
as     => [ 'date_created' ],

So the problem essentially is that your underlying object doesn't know
that your derived [ max(date_created) ] column is to cast as a DateTIme
object like it knows how to do so for the defined column
[ me.date_created ].

Therefore you either: 

a. Look here:
http://search.cpan.org/~frew/DBIx-Class-0.08123/lib/DBIx/Class/Manual/Cookbook.pod#Arbitrary_SQL_through_a_custom_ResultSource
and define your result object in a way that understands your now max
result column is to return a DateTime object from the string it gets.

b. Recast your results in a different Moose Class and co-erce the result
into a DateTime object from there.


On Mon, 2010-09-06 at 16:31 +1200, Dan Horne wrote:

> 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 <[email protected]> wrote:
> 
>         
>         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/[email protected]
>         
>         
>         
>         
>         
>         _______________________________________________
>         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/[email protected]
> 
> 
> 
> _______________________________________________
> 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/[email protected]

-- 


Regards,

Neil Lunn
IT Support E-Commerce Stream
Trixan Group of Companies


p: +61 1300 TRIXAN or +61 1300 874 926 (ext. 1206)
f: +61 2 9475 0553
e: [email protected]
w: www.trixan.com

This electronic message, including its attachments, is confidential and
may be privileged or otherwise protected. The information is solely for
the intended recipient. If you are not the intended recipient, this
message was sent to you in error and you are hereby advised that any
review, disclosure, copying, distribution or use of this message or any
of the information included in this message by you is unauthorized and
strictly prohibited. If you have received this electronic transmission
in error, please immediately and permanently delete this message and
notify the sender by collect telephone call to +61 1300 874 926 or by
reply to this e-mail message. Thank you.



<<attachment: TrixanLogo.jpg>>

_______________________________________________
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/[email protected]

Reply via email to