Re: [CDBI] Subroutine redefined

[prev] [thread] [next] [Date index for 2004/09/03]

From: William McKee
Subject: Re: [CDBI] Subroutine redefined
Date: 19:05 on 03 Sep 2004
On Fri, Sep 03, 2004 at 02:08:58PM -0400, Sean Quinlan wrote:
> Thanks William! Changing might_have to has_a seems to resolve the
> redefined error I was still getting after dropping the column
> specification as Dave suggested. However, I'm left a bit ... confused by
> that. Maybe it's my interpretation of the terms, but I don't see why one
> would cause a compile redefined error and the other not.

I understand! I've been a regular in the dazed and confused camp myself.
As for the redefined error, my interpretation is that it has to do with
how CDBI is handling the relationship behind the scenes. The actual
error is being generated by CDBI. If you get it, there's a good
indication you are incorrectly setting up CDBI.


> I also have a mnemonic problem - an applicant might have a reviewer
> ... but they might not have been assigned one yet, so wouldn't the
> has_a cause a problem at run time?!?

No. See yesterday's discussion that Peter Pimley started. There appears
to be no restriction by either CDBI or SQL that dictates that a has_a
must have a corresponding record. The foreign key field appears to fine
if left undef.


> Also, while that took care of the problems of redefined subroutines,
> this class:
> package BioInfo::DB::Qualifiers;
> use base 'BioInfo::DB::Class';
> BioInfo::DB::Qualifiers->table('Qualifiers');
> BioInfo::DB::PETP->columns(Primary => qw/Student Type/);
> BioInfo::DB::Qualifiers->columns(Essential => qw/Date Score/);
> BioInfo::DB::Qualifiers->has_a(Student => 'BioInfo::DB::Students');

Something looks wrong here. You are declaring the package as
BioInfo::DB::Qualifiers but then are setting the columns for
BioInfo::DB::PETP. I would rewrite that as the following:

  package BioInfo::DB::Qualifiers;
  use base 'BioInfo::DB::Class';
  __PACKAGE__->table('Qualifiers');
  __PACKAGE__->columns(Primary => qw/Student Type/);
  __PACKAGE__->columns(Essential => qw/Date Score/);
  __PACKAGE__->has_a(Student => 'BioInfo::DB::Students');

See if that fixes the problem. At least it will prevent typos.


> Threw this error:
> PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e"
> "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
> t/Class....has_a needs a valid column at
> /usr/lib/perl5/site_perl/5.8.3/Class/DBI/Relationship/HasA.pm line 12
> Compilation failed in require at t/Class.t line 10.
> BEGIN failed--compilation aborted at t/Class.t line 10.

I suspect that's because you are not setting any columns.


> But changing _that_ definition to:
> BioInfo::DB::Qualifiers->might_have(Student => 'BioInfo::DB::Students');

might_have must be a bit less picky about the columns not existing.


> <sigh> ... I'm going to have to read a lot of source code this weekend,
> eh? ;-}

It takes awhile to get familiar with CDBI. Read the wiki and keep
rereading the docs--they'll eventually start to make more sense to you.


Good luck,
William

        -- 
        Knowmad Services Inc.
http://www.knowmad.com

Subroutine redefined
Sean Quinlan 15:06 on 03 Sep 2004

Re: [CDBI] Subroutine redefined
William McKee 16:48 on 03 Sep 2004

Re: [CDBI] Subroutine redefined
Sean Quinlan 18:08 on 03 Sep 2004

Re: [CDBI] Subroutine redefined
William McKee 19:05 on 03 Sep 2004

Re: [CDBI] Subroutine redefined
Sean Quinlan 19:48 on 03 Sep 2004

Re: [CDBI] Subroutine redefined
William McKee 20:34 on 03 Sep 2004

Re: [CDBI] Subroutine redefined
Sean Quinlan 17:56 on 03 Sep 2004

Re: [CDBI] Subroutine redefined
Drew Taylor 18:12 on 03 Sep 2004

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