in reply to Class::DBI has_a relationships

The Class::DBI docs contain the following warning:

*NOTE* You should not attempt to make your primary key column inflate using has_a() as bad things will happen. If you have two tables which share a primary key, consider using might_have() instead.

You can use might_have in your Sessions_Metadata class and that should do the trick. Check the Class::DBI docs for the syntax.

Replies are listed 'Best First'.
Re: Re: Class::DBI has_a relationships
by CassJ (Sexton) on May 18, 2004 at 18:21 UTC
    aaaah.

    Thanks.

    I knew I was missing something.

    So if I follow jeffa's suggestion of merging the sessions and sessions_metadata tables so that I have a single sessions table with a (non-primary-key) foreign key to the users table then all should be fluffy and I can stop banging my head off the desk...?

    ...or I could use might_have, which works fine. Sigh. that'll teach me to read docs properly...

    Cheers guys,

    Cxx

Re: Re: Class::DBI has_a relationships
by drewbie (Chaplain) on May 19, 2004 at 03:02 UTC
    FYI, there was a patch submitted to the list to take care of this problem. It will be interesting to see if it passes muster and makes it into the next release. Apparently PK's are not inflated/deflated when relationships are setup on them. This causes problems when going to/from the database after updates.

    The patch: http://groups.kasei.com/mail/arc/cdbi-talk/2004-04/msg00200.html

      Thanks.

      Tried the patch and am still getting the error, but will post details to the mailing list and report back if I get a solution

      Cheers, Cxx.

        I saw your post on the mailing list. It's always best to let the big guns weigh in. I'm merely an avid user. :-)