[Dbix-class] "Deletion" of records by setting status to 'deleted'
Dmitry Latin
dim0xff at gmail.com
Tue Mar 10 17:21:33 GMT 2015
On Tuesday 10 of March 2015 17:31:27 Ilya Chesnokov wrote:
> 2015-03-10 12:45 GMT+03:00 Dmitry Latin <dim0xff at gmail.com>:
> > Hi!
> >
> >> First I tried to override search_rs() method in a custom resultset
> >> with something like this:
> >> https://gist.github.com/ichesnokov/1d4236f79c69fd14ebbe, but it didn't
> >> work as expected on prefetches with condition in them.
> >
> > I think this way doesn't work on prefetches because it shouldn't.
>
> Why?
>
Because search_rs works only with current resultset, not with related.
> > In addition to overriding search_rs, you have to provide conditions into
> > relations
> > (https://metacpan.org/pod/DBIx::Class::Relationship::Base#Custom-join-con
> > ditions)
> This seems irrelevant to my issue: I don't need custom joins, I only
> want to have what DBIx::Class provides by default.
>
> By "prefetches with condition" I mean expressions with both "prefetch"
> and "where" attributes, similar to this:
>
> $customer->find(
> $id,
> {
> prefetch => 'services',
> where => { 'services.entity' => 'abcd' },
> }
> );
>
I thought that you need to fetch customer and in addition fetch all not
deleted services for that customer - here at least you get customer without
services.
But your example tells: "fetch customer and in addition fetch all services,
where services not deleted" - here it is possible to get empty result.
So, probably I misunderstood your problem.
--
//wbr, Dmitry Latin
More information about the DBIx-Class
mailing list