[Dbix-class] Adding a case statement to a ResultSet

Kenneth S Mclane ksmclane at us.ibm.com
Fri May 4 16:12:34 GMT 2012


I need to get this working and cannot figure out where my error is. This 
code:

sub list :Local {
        my ($self, $c, $page) = @_;
        $page = $c->req->param('page') || 1;
        my $rs = $c->model('ORANGES::Account')->search_rs(undef, { 
                '+select' => [ "case when sunset_date is not null then 
'Sunset'
                                            when approval_date is not null 
then 'Complete'
                                        when approval_date is null then
                                        case when g.percent_complete < 100 

                                                then 'Pending 
Installation'
                                        else 'Pending Approval'
                                        end
                                end" ], 
                '+as' => [ 'account_status' ], 
                order_by => 'account_code',
                prefetch => {
                        account_id => 'progress',
                        account_id => 'metrics',
                        account_id => 'compliance',
                        department_id => 'department_id',
                },
                rows => 15,
                page => $page,
         });
        $c->stash(accounts => $rs);
        $c->stash(pager => $rs->pager());
        $c->stash(status => "");
        $c->stash->{'template'}=>'accountview/list';
}

adds the case statement to the sql, but I get an error that "sunset_date" 
is ambiguous. If I specify it as "account.sunset_date" I get 
"account.sunset_date is invalid in the context it is being used in."

I don't know what it wants.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20120504/4e8908ac/attachment.htm


More information about the DBIx-Class mailing list