[Dbix-class] Literals in relationship join criteria?

Mark Blythe list at markblythe.com
Mon May 8 09:19:56 CEST 2006


I'm trying to set up a has_one relationship where the join criteria requires
a literal.  I have a generic code lookup table called 'simple_code' with the
following columns:


The group name column would be something like 'state' (for U.S. state
codes), 'user_status', etc.  The primary key is group_name + code.  This
idea is to avoid having dozens of specialized code tables (and classes) with
identical layouts.

Setting up a class to represent this table is no problem.  The problem comes
when I try to define a relationship to it from a table which holds a code.
Let's say My::DB::User has a column named "status_code" which maps to rows
in simple_code with group_name = 'user_status'.  I'd like to do something

My::DB::User->has_one(status => 'My::DB::SimpleCode', {
   'foreign.code' => 'self.status_code',
   'foreign.group_name' => 'user_status'  # <-- should represent the literal
value 'user_status'

Is there any way to accomplish this?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rawmode.org/pipermail/dbix-class/attachments/20060508/05a69d5a/attachment.htm 

More information about the Dbix-class mailing list