[Dbix-class] 2-argument SQL agregates

Doran L. Barton fozz at iodynamics.com
Tue Mar 28 17:57:05 CEST 2006


I need some help figuring out if it's possible, and if so how, to
specify a 2-argument aggregate function for a search query using
DBIx::Class.

The examples in the docs say you can do this:

	my $rs = $schema->resultset(’Artist’)->search(
            {},
            {
              select => [ ’name’, { LENGTH => ’name’ } ],
              as     => [qw/ name name_length /],
            }
          );

This basically does:

	SELECT name, LENGTH('name') AS name_length FROM Artist

I specifically need to use the TO_CHAR() function which takes a field
name and a format string:

	SELECT foo, TO_CHAR('bar', 'Month DD YYYYY') FROM Artist

Anyone done this?

-=Fozz

-- 
fozz at iodynamics.com is Doran L. Barton, president, Iodynamics LLC
Iodynamics: Linux solutions - Web development - Business connectivity
  "For Sale. Three canaries of undermined sex."
     -- Seen in a newspaper ad




More information about the Dbix-class mailing list