Re: has_a with complex primary keys

[prev] [thread] [next] [Date index for 2004/10/08]

From: Y00R0B0T
Subject: Re: has_a with complex primary keys
Date: 21:55 on 08 Oct 2004
hi,
The docs state pretty clearly that  multi-column foreign keys are not
supported.

The work around I've got from this list works pretty well for most cases:	

Perrin Harkins 	
<perrin@xxxx.xxx> to me, cdbi-talk
I've done this quite a bit with no problems.  I just made my own simple
method:

sub foreign_obj {
    my $self = shift;
    my $foreign_obj = Foreign::Class->retrieve(
                                               key1 => $self->key1(),
                                               key2 => $self->key2(),
                                              );
    return $foreign_obj;
}

It doesn't do everything that has_a normally does (e.g. this is just a
getter, not a get/set) but you can make it do more if you need to.
Support in has_a would be nice at some point."  
"

-james 

On Fri, 8 Oct 2004 17:13:55 -0400, Ricardo SIGNES
<rjbs-perl-cdbi@xxxxx.xxxxxxx.xxx> wrote:
> Thanks to a private email, I felt goaded on to make the errors I'm
> getting clearer.
> 
> I've made a -very- simple test for this, which I've attached.  The db is
> a SQLite database made with a recent DBD::SQLite.  The results of the
> test are as follows:
> 
>  ok 1 - use RJBS::Batch;
>  ok 2 - The object isa RJBS::Batch
>  ok 3 - got 1
>  ok 4 - three units in batch 1
>  ok 5 - first stringifies correctly
>  Can't deflate unitid: 1 is not a RJBS::Unit at
>  /usr/local/lib/perl5/site_perl/5.8.5/Class/DBI/Relationship/HasMany.pm
>  line 118
>  1..5
>  # Looks like your test died just after 5.
> 
> This bears out the results I got on my Win32 machine using the more
> complex tables (with the same kind of structure) and Class::DBI::MSSQL.
> 
> Just to make sure I'm not an idiot as far as data-loading goes, here's
> what dbish has to say about the table from which it should be pulling
> its data:
> 
>  @> SELECT * FROM test WHERE batchid=1 AND unitid=1;
>  batchid,unitid,testid
>  1,1,1
>  [1 rows of 3 fields returned]
>  @>
> 
> --
> rjbs
> 
> 
>

has_a with complex primary keys
Ricardo SIGNES 19:08 on 08 Oct 2004

Re: has_a with complex primary keys
Ricardo SIGNES 21:13 on 08 Oct 2004

Re: has_a with complex primary keys
Y00R0B0T 21:55 on 08 Oct 2004

Generated at 11:34 on 01 Dec 2004 by mariachi v0.52