Multicolumn primary keys + relationships

[prev] [thread] [next] [Date index for 2005/02/24]

From: Crossfire
Subject: Multicolumn primary keys + relationships
Date: 05:31 on 24 Feb 2005
I'm relatively new to CDBI, and I've become aware that relationships
using a multicolumn primary key currently are not supported.

my current db schema has quite a few places where I use a 2-3 column
primary key, and then use that (with matching foreign key) to refer to
a parent table...

From what I've been able to deduct from the documentation, CDBI
assumes that you only have a single value key if you want to
use a relationship of any kind.

Now, I had a look, and attempts to use might_have to link these tables
failed...

I had a quick peek, and I would appreciate if anybody can confirm if
this idea will work or not, if it will break anything major internally
(nevermind user code just yet - I don't know the gritty details of
exactly how much carnage a change like this might cause) and if its a
reasonable idea or not.

The idea is to to change ->retrieve() to support hashrefs + change
CDBI's default value to be a suitable reference to a hash of the
primary key column namess and values if there is more than a single
column in the primary key.  (Rather than the current
'value/value/value' style value for tables with multicolumn primary
keys)

With that change, if I'm not mistaken, might_have should be able to
work with multicolumn primary keys...  (barring any other serious
issues I may have missed)

Comments?  Flames?

C.

Multicolumn primary keys + relationships
Crossfire 05:31 on 24 Feb 2005

Re: Multicolumn primary keys + relationships
Peter Speltz 08:59 on 24 Feb 2005

Generated at 22:43 on 24 Feb 2005 by mariachi v0.52