[jifty-devel] Queries using GROUP BY and aggregate functions

Andrew Sterling Hanenkamp sterling at hanenkamp.com
Sat Jul 7 11:07:57 EDT 2007


On 7/6/07, Jesse Vincent <jesse at bestpractical.com> wrote:
> Does this help?

In the sense that it tells me I'm sane in doing this, yes. In the
sense that it fixes my problem, no.

The basic issue remains:

FATAL - Can't call method "check_read_rights" on an undefined value at
/Library/Perl/5.8.6/Jifty/Collection.pm line 71.

It croaks as soon as I call ->next. I should mention that this query
will regularly be operating on an empty result and the table is
currently empty (after the application is installed it would be an
empty result because their just aren't any matching rows). I suppose
that it could be barfing because there aren't any records to load just
now.

>
>      my $choices = Doxory::Model::ChoiceCollection->new();
>      $choices->unlimit;
>      $choices->group_by( function => "SUBSTR(created,1,10)" );
>      my $date_name = $choices->column(
>          function => 'SUBSTR(created,1,10)',
>          column   => 'date'
>      );
>      my $count_name = $choices->column( function => 'COUNT', column
> => 'id' );
>      $choices->order_by( function => 'SUBSTR(created,1,10)', order =>
> 'DESC' );
>      $choices->rows_per_page(10);
> my $data;
>              while ( my $choice = $choices->next ) {
>                  $data->{$choice->{'values'}{ 'date' } } = $choice-
>  >__value('id');
>                      };


More information about the jifty-devel mailing list