[Dbix-class] Excluding columns from a query

Nick Wellnhofer wellnhofer at aevum.de
Fri Feb 12 14:12:41 GMT 2010


On 12.02.2010 14:40, Rob Kinyon wrote:
>>> my $rs2 = $rs->search(
>>>     undef,
>>>     {
>>>         columns => [ grep { $_ ne 'exclude_me' } $rs->resultsource->columns ]
>>>     }
>>> );
>>
>> Thanks for the tip. I keep forgetting about the usefulness of the grep
>> function. But that doesn't work with prefetch. I think something like
>> this would be handy:
>>
>> $rs->search(
>>    undef,
>>    {
>>        prefetch => 'related',
>>        exclude  => [ 'me.exclude_me', 'related.exclude_me_too' ],
>>    }
>> );
> 
> It -shouldn't- work with prefetch as prefetch is just an optimization.
> 
> You also still haven't mentioned -WHY- you want this.

I think I did. It's because I'm lazy and being able to do something like
my example above would save me from writing more code to achieve the
same thing.

I understand that this would change the contents of prefetched rows
compared to non-prefetched rows, so it's possibly a bad idea.

Nick



More information about the DBIx-Class mailing list