[Dbix-class] Get a list of parent objects based on child object properties (possible n00bish question)

David Ihnen davidi at norchemlab.com
Wed Feb 4 22:30:15 GMT 2009


Heiko Gruner wrote:
> Hello,
> i tried to hardcode values into a table relationship like below.
> But i just received just errors like
>
> "undef error - Invalid rel cond val"
>
That sucks, eh Heiko?  Yes, what I was saying below is "I know what you 
mean and this is how I want it to work, but it does not work that way"
>
> I am desparatly looking for a solution ...
Are you desperate enough to donate your time to patch 
DBIx::Class::Relationship and related code so that this works the way we 
expect?

Are you desperate enough to use the acessors and back-prefetch method?

Are you desperate enough to use the related_resultset query sequences?
> Please help ...
I'm sure more than one of the list members, me included, could be 
persuaded with sufficient lubrication to work on the issue... But I'm 
not sure what more help I can be here beyond that.  YES it is an issue.  
The rest of my message (a fragment of which you quoted below) is 
essentially the solution that I am aware of to get around the somewhat 
annoying inability to define complex relational join terms.

David

>
> ...
>> Hm.  What you would do in manual sql amount to defining a new 
>> relation, one called 'active_attributes' maybe.  That has a compound 
>> join condition (aid = aid and active = 1)
>>
>> FROM projects p
>> JOIN project_attributes pa ON (pa.pid = p.pid and pa.active = 1)
>>
>> Which I would *expect* to define as
>>
>> __PACKAGE__->has_many('active_attributes', 
>> 'DB::Schema::project_attribute', { 'foreign.pid' => 'self.pid', 
>> self.active => 1 });
>>
>




More information about the DBIx-Class mailing list