[Dbix-class] Excluding columns from a query

Rob Kinyon rob.kinyon at gmail.com
Fri Feb 12 03:49:57 GMT 2010


On Thu, Feb 11, 2010 at 17:24, Darren Duncan <darren at darrenduncan.net> wrote:
> Nick Wellnhofer wrote:
>>
>> If I want to exclude a single column from a query I currently have to list
>> all columns except the one to be excluded in the 'columns' attribute. This
>> is cumbersone and AFAICS doesn't work with prefetch. It would be nice if I
>> could simply pass a list of all the columns I want to be excluded including
>> prefetched ones.
>>
>> Or am I missing something?
>
> I don't know if you can do that, but it is certainly a very reasonable thing
> to want to do. -- Darren Duncan

my $rs2 = $rs->search(
    undef,
    {
        columns => [ grep { $_ ne 'exclude_me' } $rs->resultsource->columns ]
    }
);

You can also exclude them at the ResultSet level - I leave finding out
how as an exercise for the reader.

Rob



More information about the DBIx-Class mailing list