[Dbix-class] help on group_by and select as?

Jess Robinson castaway at desert-island.demon.co.uk
Fri Jul 7 12:14:55 CEST 2006


?me points to docs for "as" in DBIx::Class::ResultSet:

Please note: This will NOT insert an C<AS employee_count> into the SQL 
statement produced, it is used for internal access only. Thus attempting 
to use the accessor in an C<order_by> clause or similar will fail 
misrably.

Jess


On Fri, 7 Jul 2006, fayland wrote:

> mmm, I have some code like this:
>
> my $it = $dbic_data->resultset('table_name')->search( {
>        want => $want,
>    }, {
>        select   => [ 'a', 'b', { max => 'c' } ],
>        as       => [ 'a', 'b', 'max_cid' ],
>        group_by => [qw/ a b /],
>        order_by => 'max_cid DESC',
>        page     => 1,
>        rows     => 10
>    } );
>
> debug info shows:
>
> DBIx::Class::ResultSet::all(): Error executing 'SELECT a, b, MAX( c )
> FROM table_name me WHERE ( want = ? ) GROUP BY a, b ORDER BY max_cid
> DESC LIMIT 10': Unknown column 'max_cid' in 'order clause' at
>
> seems as => is not working? my code is anything wrong?
>
> When I comment the "order_by => 'max_cid DESC', it complains like this:
> |
> DBIx::Class::ResultSet::pager(): Error executing 'SELECT COUNT(
> DISTINCT( a, b ) ) FROM table_name me WHERE ( want = ? )': Operand
> should contain 1 column(s) at
>
> I don't know why? mm, I tried |0.06999_05
> <http://search.cpan.org/%7Ejguenther/DBIx-Class-0.06999_05/> and
> 0.06003, both no luck.
>
> Thanks in advanced.
>
> -- 
> Fayland Lam // http://www.fayland.org/
>
>
> _______________________________________________
> List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
> Wiki: http://dbix-class.shadowcatsystems.co.uk/
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
> Searchable Archive: http://www.mail-archive.com/dbix-class@lists.rawmode.org/
>
>



More information about the Dbix-class mailing list