[Dbix-class] might_have join condition with value rather than column
Henry Drinkwater
henry.drinkwater at googlemail.com
Sun Jul 13 22:18:02 BST 2008
Hi,
I am trying to create a might_have join condition in DBIx::Class where I
want to add a value comparison as well as having matching values in the
foreign and self columns. To give an example, suppose I have two tables:
create table foo (
id int not null primary key auto_increment,
etc
)
create table bar (
id int not null primary key auto_increment,
foo_id int not null,
pref boolean not null
etc
)
and I want to generate SQL that looks something like this:
select me.id, bar.id from foo me
left join bar bar on (me.id =3D bar.foo_id and bar.pref =3D 1)
etc
I tried creating my might_have relationship with various variations along
this line in Schema::Foo:
__PACKAGE__->might_have(bar =3D> 'Schema::Bar',
{
'foreign.foo_id' =3D> 'self.id',
'foreign.pref' =3D> { '=3D=3D', '1' },
});
but couldn't find anything that worked - I get an exception thrown like
this:
Invalid rel cond val HASH(0x94a79c)
for all the things I tried. Is this kind of join possible and if so what is
the right syntax?
thanks
Henry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20080713/c2e=
18b90/attachment.htm
More information about the DBIx-Class
mailing list