Skip Menu |
 

This queue is for tickets about the DBIx-Class CPAN distribution.

Report information
The Basics
Id: 105349
Status: open
Priority: 0/
Queue: DBIx-Class

People
Owner: Nobody in particular
Requestors: jon.rubin [...] grantstreet.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)

Attachments
DBIx::Class::Row-has_relationship_loaded.patch



Subject: Add check to see if relationship has loaded
Date: Thu, 18 Jun 2015 16:17:20 -0400
To: bug-DBIx-Class [...] rt.cpan.org
From: Jon Rubin <jon.rubin [...] grantstreet.com>
Download (untitled) / with headers
text/plain 1.3k
Hi, I recently came across a case where I wanted to determine if a relationship on a row was already loaded before accessing it. Frequently, the relation would be a circular reference, and there was no reason to hit the database if this was the case. However, if the relationship *was* already loaded, then I wanted to return the loaded copy (eg. to preserve prefetch functionality). Maybe code will explain better: sub get_original_foo { my ($self) = @_; if ( $self->get_column('foo_id') == $self->get_column('original_foo_id') ) { # If we've already prefetched the original_foo, return that. # Otherwise we'll lose out on any benefits gained by prefetching other # DB objects through original_foo # Ideally would check $self->has_relationship_loaded('original_foo') return $self unless exists $self->{_relationship_data}{original_foo} || exists $self->{_inflated_column}{original_foo}; } return $self->original_foo; } I've given the fix a go in the attached patch, written for DBIx-Class-Row-0.082810 (it includes documentation and test updates). FWIW, I'm running perl v5.10.1, on both Mac and Linux. Let me know if there's an existing solution I've missed. Otherwise, if this makes sense, I can submit the patch in git. -- Jon Rubin Grant Street Group Ph: (412) 391-5555, Ext. 1323

Message body is not shown because sender requested not to inline it.

Subject: Re: [rt.cpan.org #105349] Add check to see if relationship has loaded
Date: Fri, 19 Jun 2015 14:47:19 +0200
To: bug-DBIx-Class [...] rt.cpan.org
From: Peter Rabbitson <ribasushi [...] cpan.org>
Download (untitled) / with headers
text/plain 2.6k
On 06/18/2015 10:17 PM, Jon Rubin via RT wrote: Show quoted text
> Thu Jun 18 16:17:35 2015: Request 105349 was acted upon. > Transaction: Ticket created by jon.rubin@grantstreet.com > Queue: DBIx-Class > Subject: Add check to see if relationship has loaded > Broken in: (no value) > Severity: (no value) > Owner: Nobody > Requestors: jon.rubin@grantstreet.com > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=105349 > > > > Hi, > > I recently came across a case where I wanted to determine if a relationship > on a row was already loaded before accessing it. Frequently, the relation > would be a circular reference, and there was no reason to hit the database > if this was the case. However, if the relationship *was* already loaded, > then I wanted to return the loaded copy (eg. to preserve prefetch > functionality). > > Maybe code will explain better: > > sub get_original_foo > { > my ($self) = @_; > > if ( $self->get_column('foo_id') == > $self->get_column('original_foo_id') ) { > # If we've already prefetched the original_foo, return that. > # Otherwise we'll lose out on any benefits gained by prefetching > other > # DB objects through original_foo > > # Ideally would check $self->has_relationship_loaded('original_foo') > > > return $self unless exists $self->{_relationship_data}{original_foo} > || exists $self->{_inflated_column}{original_foo}; > } > return $self->original_foo; > } > > > I've given the fix a go in the attached patch, written for > DBIx-Class-Row-0.082810 > (it includes documentation and test updates). > > FWIW, I'm running perl v5.10.1, on both Mac and Linux. > > Let me know if there's an existing solution I've missed. Otherwise, if this > makes sense, I can submit the patch in git. >
Hi! Thank you for the contribution. This was an already-requested feature with a patch similar to your written and living under the branch 'people/abraxxa/has_relationship_loaded'. The reason it never merged was because at the time several corner cases were encountered that didn't have an easy solution, and the gneral understanding of the interactions with IC were poorly understood by pretty much all maintainers (me included). With that said - it is probably time to revisit this work. I will try my best to do so in the next week, and will see whether yours or abraxxa's work can be incorporated in a better manner. Please do bug me if you do not hear anything by the end of the month - there is currently another project that keeps distracting me, so I may end up dropping this on the floor (again). Thanks!
Subject: Re: [rt.cpan.org #105349] Add check to see if relationship has loaded
Date: Thu, 9 Jul 2015 09:13:26 -0400
To: bug-DBIx-Class [...] rt.cpan.org
From: Jon Rubin <jon.rubin [...] grantstreet.com>
Download (untitled) / with headers
text/plain 3.1k
Hi Peter! Just checking in on the status of this - you told me to bother you if I hadn't heard anything by the end of June :) Cheers, Jon On Fri, Jun 19, 2015 at 8:47 AM, Peter Rabbitson via RT < bug-DBIx-Class@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=105349 > > > On 06/18/2015 10:17 PM, Jon Rubin via RT wrote:
> > Thu Jun 18 16:17:35 2015: Request 105349 was acted upon. > > Transaction: Ticket created by jon.rubin@grantstreet.com > > Queue: DBIx-Class > > Subject: Add check to see if relationship has loaded > > Broken in: (no value) > > Severity: (no value) > > Owner: Nobody > > Requestors: jon.rubin@grantstreet.com > > Status: new > > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=105349 > > > > > > > Hi, > > > > I recently came across a case where I wanted to determine if a
> relationship
> > on a row was already loaded before accessing it. Frequently, the relation > > would be a circular reference, and there was no reason to hit the
> database
> > if this was the case. However, if the relationship *was* already loaded, > > then I wanted to return the loaded copy (eg. to preserve prefetch > > functionality). > > > > Maybe code will explain better: > > > > sub get_original_foo > > { > > my ($self) = @_; > > > > if ( $self->get_column('foo_id') == > > $self->get_column('original_foo_id') ) { > > # If we've already prefetched the original_foo, return that. > > # Otherwise we'll lose out on any benefits gained by prefetching > > other > > # DB objects through original_foo > > > > # Ideally would check
> $self->has_relationship_loaded('original_foo')
> > > > > > return $self unless exists
> $self->{_relationship_data}{original_foo}
> > || exists
> $self->{_inflated_column}{original_foo};
> > } > > return $self->original_foo; > > } > > > > > > I've given the fix a go in the attached patch, written for > > DBIx-Class-Row-0.082810 > > (it includes documentation and test updates). > > > > FWIW, I'm running perl v5.10.1, on both Mac and Linux. > > > > Let me know if there's an existing solution I've missed. Otherwise, if
> this
> > makes sense, I can submit the patch in git. > >
> > Hi! > > Thank you for the contribution. This was an already-requested feature > with a patch similar to your written and living under the branch > 'people/abraxxa/has_relationship_loaded'. The reason it never merged was > because at the time several corner cases were encountered that didn't > have an easy solution, and the gneral understanding of the interactions > with IC were poorly understood by pretty much all maintainers (me > included). > > With that said - it is probably time to revisit this work. I will try my > best to do so in the next week, and will see whether yours or abraxxa's > work can be incorporated in a better manner. Please do bug me if you do > not hear anything by the end of the month - there is currently another > project that keeps distracting me, so I may end up dropping this on the > floor (again). > > Thanks! > >
-- Jon Rubin Grant Street Group Ph: (412) 391-5555, Ext. 1323
Subject: Re: [rt.cpan.org #105349] Add check to see if relationship has loaded
Date: Mon, 13 Jul 2015 15:02:07 +0200
To: bug-DBIx-Class [...] rt.cpan.org
From: Peter Rabbitson <ribasushi [...] cpan.org>
Download (untitled) / with headers
text/plain 557b
On 07/09/2015 03:13 PM, Jon Rubin via RT wrote: Show quoted text
> Queue: DBIx-Class > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=105349 > > > Hi Peter! > > Just checking in on the status of this - you told me to bother you if I > hadn't heard anything by the end of June :) > >
Unfortunately there are no news yet, as I am slowly slogging through the rather ossified relationship system :( Please re-poke me at the end of this month, as I am likely to not have anything before then. Sorry once again - work is progressing, just very very slowly.
Subject: Re: [rt.cpan.org #105349] Add check to see if relationship has loaded
Date: Tue, 14 Jul 2015 10:17:07 -0400
To: bug-DBIx-Class [...] rt.cpan.org
From: Jon Rubin <jon.rubin [...] grantstreet.com>
Download (untitled) / with headers
text/plain 868b
No problem, I'll remind you in a few weeks. Thanks! Jon On Mon, Jul 13, 2015 at 9:02 AM, Peter Rabbitson via RT < bug-DBIx-Class@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=105349 > > > On 07/09/2015 03:13 PM, Jon Rubin via RT wrote:
> > Queue: DBIx-Class > > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=105349 > > > > > Hi Peter! > > > > Just checking in on the status of this - you told me to bother you if I > > hadn't heard anything by the end of June :) > > > >
> > Unfortunately there are no news yet, as I am slowly slogging through the > rather ossified relationship system :( Please re-poke me at the end of > this month, as I am likely to not have anything before then. > > Sorry once again - work is progressing, just very very slowly. > >
-- Jon Rubin Grant Street Group Ph: (412) 391-5555, Ext. 1323
Subject: Re: [rt.cpan.org #105349] Add check to see if relationship has loaded
Date: Tue, 11 Aug 2015 10:19:21 -0400
To: bug-DBIx-Class [...] rt.cpan.org
From: Jon Rubin <jon.rubin [...] grantstreet.com>
Download (untitled) / with headers
text/plain 1.1k
Hi Peter, Just doing my monthly checkin on the status of the 'has_relationship_loaded' feature in DBIx. Any progress? Hope all else is well. Thanks! On Tue, Jul 14, 2015 at 10:17 AM, Jon Rubin <jon.rubin@grantstreet.com> wrote: Show quoted text
> No problem, I'll remind you in a few weeks. Thanks! > > Jon > > On Mon, Jul 13, 2015 at 9:02 AM, Peter Rabbitson via RT < > bug-DBIx-Class@rt.cpan.org> wrote: >
>> <URL: https://rt.cpan.org/Ticket/Display.html?id=105349 > >> >> On 07/09/2015 03:13 PM, Jon Rubin via RT wrote:
>> > Queue: DBIx-Class >> > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=105349 > >> > >> > Hi Peter! >> > >> > Just checking in on the status of this - you told me to bother you if I >> > hadn't heard anything by the end of June :) >> > >> >
>> >> Unfortunately there are no news yet, as I am slowly slogging through the >> rather ossified relationship system :( Please re-poke me at the end of >> this month, as I am likely to not have anything before then. >> >> Sorry once again - work is progressing, just very very slowly. >> >>
> > > -- > Jon Rubin > Grant Street Group > Ph: (412) 391-5555, Ext. 1323 >
-- Jon Rubin Grant Street Group Ph: (412) 391-5555, Ext. 1323
Download (untitled) / with headers
text/plain 349b
On Tue Aug 11 16:19:36 2015, jon.rubin@grantstreet.com wrote: Show quoted text
> Hi Peter, > > Just doing my monthly checkin on the status of the > 'has_relationship_loaded' feature in DBIx. Any progress? >
Hi. I am looking at having this in place in a trial release available for testing the by the end of the second week of Sept. Sorry for the string of delays.
Subject: Re: [rt.cpan.org #105349] Add check to see if relationship has loaded
Date: Tue, 1 Sep 2015 09:14:46 -0400
To: bug-DBIx-Class [...] rt.cpan.org
From: Jon Rubin <jon.rubin [...] grantstreet.com>
Download (untitled) / with headers
text/plain 745b
No problem at all. We're similarly swamped on our end, and probably won't get a chance to pull in any new modules until at least that point anyway! Jon On Thu, Aug 27, 2015 at 3:59 AM, Peter Rabbitson via RT < bug-DBIx-Class@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=105349 > > > On Tue Aug 11 16:19:36 2015, jon.rubin@grantstreet.com wrote:
> > Hi Peter, > > > > Just doing my monthly checkin on the status of the > > 'has_relationship_loaded' feature in DBIx. Any progress? > >
> > Hi. I am looking at having this in place in a trial release available for > testing the by the end of the second week of Sept. Sorry for the string of > delays. >
-- Jon Rubin Grant Street Group Ph: (412) 391-5555, Ext. 1323


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.