Skip Menu |
 

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

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

People
Owner: ribasushi [...] leporine.io
Requestors: abraxxa [...] cpan.org
koenc [...] dalicon.com
Cc: gortan [...] cpan.org
AdminCc:

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



Subject: relationship where attrs are ignored when prefetching a rel
Download (untitled) / with headers
text/plain 555b
When prefetching this relationship the where attribute is ignored while it is used when calling $row->currently_affected_by_maintenance without prefetch: __PACKAGE__->has_many('currently_affected_by_maintenance', 'NAC::Model::DBIC::Table::View_Interface_Affected_By_Maintenance', 'fk_interface', { join => 'rel_maintenance', where => { 'rel_maintenance.datetime_start' => \'<= sys_extract_utc(SYSTIMESTAMP)', 'rel_maintenance.datetime_end' => \'>= sys_extract_utc(SYSTIMESTAMP)', }, } );
CC: "'K. Cuelenaere'" <koenc [...] dalicon.com>
Subject: "where" attribute for DBIx::Class::RelationShip does no longer seem to be functional
Date: Tue, 23 Aug 2011 14:59:09 +0200
To: bug-DBIx-Class [...] rt.cpan.org
From: Koen Cuelenaere <koenc [...] dalicon.com>
Hi there, according to the documentation we should be able to in the Relationship class, use the "where" attribute for filtering relationships. I've tried to do that in the latest DBIx::Class version (0.08195) and it doesn't work, nor do I see the code looking out for that "where" attribute. It results in SQL where the filter has not been applied to, so returns incorrect results. This is the definition that I try to do: __PACKAGE__->has_many( "articles_has_article_galleys_pdf", "pharmaventures::Storage::Schema::OJS::ArticleGalleys", { "foreign.article_id" => "self.article_id", # "foreign.label" => \"pdf" }, { join_type => 'left', where => { label => "pdf" } } ); PS: mind the commented line: in an earlier version of DBIx::Class I succesfully made a patch that uses a string ref as an alternative way of filtering the relationship. That code is now harder to reimplement in the latest DBIx::Class code alas. regards Koen -- ---------------------------------------------------------- Please be informed that as of January 1st 2011 Dalicon has a new visiting address and telephone number. Koen Cuelenaere, MSc Dalicon BV P.O. Box 354 Tel: +31 (0) 317 479 760 6700 AJ Wageningen Fax: +31 (0) 317 479 666 Mobile: +31 (0) 653 325 402 Visiting address Agro Business Park 26 6708 PW Wageningen The Netherlands http://www.dalicon.com/ Email: K.Cuelenaere@dalicon.com --------------------------------------------------------- The contents of this message, as well as any enclosures, are addressed personally to, and thus solely intended for the addressee. They may contain information regarding a third party. A recipient who is neither the addressee, nor empowered to receive this message on behalf of the addressee, is kindly requested to immediately inform the sender of receipt. Any use of the contents of this message and/or of the enclosures by any other person than the addressee is illegal towards the sender and the aforementioned third party.
Download (untitled) / with headers
text/plain 2.5k
On Tue Aug 23 08:59:47 2011, koenc@dalicon.com wrote: Show quoted text
> Hi there,
Hi! (and sorry for the untimely reply) Show quoted text
> according to the documentation we should be able to in the > Relationship class, use the "where" attribute for filtering > relationships. I've tried to do that in the latest DBIx::Class > version (0.08195) and it doesn't work, nor do I see the code > looking out for that "where" attribute. It results in > SQL where the filter has not been applied to, so returns > incorrect results. > > This is the definition that I try to do: > > __PACKAGE__->has_many( > "articles_has_article_galleys_pdf", > "pharmaventures::Storage::Schema::OJS::ArticleGalleys", > { > "foreign.article_id" => "self.article_id", > # "foreign.label" => \"pdf" > }, > { join_type => 'left', > where => { > label => "pdf" > } > } > ); > > PS: mind the commented line: in an earlier version > of DBIx::Class I succesfully made a patch that uses > a string ref as an alternative way of filtering the > relationship. That code is now harder to reimplement > in the latest DBIx::Class code alas. >
You have several unrelated things here, so I will try to deconstruct: 1) A left join with a where clause makes no sense (it will *never* do what you expect it to do). Consider: SELECT * FROM artists a LEFT JOIN cds c ON a.id = c.cd_id WHERE c.year = 2000 vs SELECT * FROM artists a LEFT JOIN cds c ON a.id = c.cd_id AND c.year = 2000 Based on the things you gave above you seem to understand this, so perhaps the only confusion is that you assumed where will translate to an ON clause - this is not the case: a where is a where 2) You did not show your invocation, but I suspect the where was "ignored" during prefetch (not during a search_related call). If this is the case this looks like a bug duplicate of https://rt.cpan.org/Ticket/Display.html?id=63709. If this is the case it is an (obviously) known issue, with an annoyingly involved fix. Due to the limited utility of the where attr, this bug has not been as of yet fixed. 3) On your local patch of dbic to use stringrefs - istr you submitting something similar to the ML which was rejected with a good reason (or maybe it wasn't you, anyhow). The correct way to do this in recent versions is through a coderef condition specification as described in detail here: http://search.cpan.org/~abraxxa/DBIx-Class-0.08195/lib/DBIx/Class/Relationship/Base.pm#condition (look for the paragraph "To specify joins which describe more than a simple equality...") Let me know your thought on the above points. Cheers
Lower prio
Download (untitled) / with headers
text/plain 132b
Stalling ticket - no reply from OP, and it's almost certain it is a duplicate. Adding a link to the seemingly related issue instead.
Download (untitled) / with headers
text/plain 202b
Just an update for everyone watching - this is an acknowledged bug and needs fixing. I am looking into this subsystem today, maybe something will fall out as a result. Apologies for the massive delay :(
Download (untitled) / with headers
text/plain 274b
Another update - the feature had to go again on the back burner. There is now a clear path forward on how to solve this, but the complications with the current RC are forcing me to reschedule solving this towards end of September. Apologies for the delay to all involved :(
Subject: Re: [rt.cpan.org #63709] relationship where attrs are ignored when prefetching a rel
Date: Mon, 15 Sep 2014 12:42:38 +0200
To: bug-DBIx-Class [...] rt.cpan.org
From: Koen Cuelenaere <koenc [...] dalicon.nl>
Download (untitled) / with headers
text/plain 483b
On 04.09.2014 09:22, Peter Rabbitson via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=63709 > > > Another update - the feature had to go again on the back burner. There > is now a clear path forward on how to solve this, but the > complications with the current RC are forcing me to reschedule solving > this towards end of September. > > Apologies for the delay to all involved :(
Hi there; no worries. We found a workaround. thanks for the updates though. Koen


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.