Re: Problem with empty has_a

[prev] [thread] [next] [Date index for 2005/05/20]

From: Thomas Klausner
Subject: Re: Problem with empty has_a
Date: 07:39 on 20 May 2005
Hi!

On Fri, May 20, 2005 at 09:05:01AM +0200, Thomas Klausner wrote:

> In fact might_have works as well. D'oh!

Well, after more testing: It only works in one direction.

Here's what I'm trying to do:

- I have a bunch of events.
- I have another bunch of publications.
- A publication might be releated to a single event (e.g. a paper of a
  presentation given at an event).
- An event might have several publications releated to it.
- Provide links between both events and publications.

My initial plan was:

My::Publication->has_a(event=>'My::Event');
My::Event->has_many(publications=>'My::Publications'=>'event');

This worked, but every publication had an empty event (as in my original
posting)


So I switched to:

My::Publication->might_have(event=>'My::Event');
My::Event->has_many(publications=>'My::Publications'=>'event');

But this does not work, because has_many doesn't find the 'event' field in
publications ("event is not a column of My::Publikations")


Now I could simply write some work-aournd code using my first attempt:
sub My::Publication::clean_event {
    my $event=shift->event;
    return $event if $event->id > 0;
}

But I'd rather find a general solution. Whether this is a patch to
Class::DBI or a special Class::DBI::Relationship on CPAN I don't care.

I would just need a pointer to what you (Tony and all others) prefere..


        -- 
        #!/usr/bin/perl                               http://domm.zsi.at
for(ref bless{},just'another'perl'hacker){s-:+-$"-g&&print$_.$/}

Problem with empty has_a
Thomas Klausner 19:34 on 19 May 2005

Re: Problem with empty has_a
Tony Bowden 21:01 on 19 May 2005

Re: Problem with empty has_a
Thomas Klausner 07:05 on 20 May 2005

Re: Problem with empty has_a
Thomas Klausner 07:39 on 20 May 2005

Re: Problem with empty has_a
merlyn (Randal L. Schwartz) 12:20 on 20 May 2005

Re: Problem with empty has_a
Tony Bowden 12:33 on 20 May 2005

Re: Problem with empty has_a
Perrin Harkins 13:43 on 20 May 2005

Generated at 15:51 on 25 May 2005 by mariachi v0.52