Re: Class::DBI::Relationship::IsA issues with create()

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

From: jldommer
Subject: Re: Class::DBI::Relationship::IsA issues with create()
Date: 20:48 on 26 Feb 2005
No, I actually am using 'Class::DBI::Relationship::IsA', not 'has_a', although 
something else that I've noticed about the 'is_a' relationship is that it 
doesn't seem to work with the 'has_many' relationship.  Of course, based on the 
definition of an ISA relationship in general database terms, I'm not entirely 
sure that that is incorrect.

Jennifer

Quoting David Naughton <naughton@xxx.xxx>:

> s/is_a/has_a/ ? I assume that's what you meant, maybe it was just a typo
> in your message. Anyway, you'll also need to add to TestDBIsA::Person:
> 
> TestDBIsA::Person->has_many( artists => 'TestDBIsA::Artist' );
> 
> Does that help?
> 
> David
> 
> On Fri, Feb 25, 2005 at 05:52:18PM +0000, jldommer@xxxx.xxxxx.xxx wrote:
> > Hi all,
> > 
> > I am using 'Class::DBI::Relationship::IsA' on a simple test database, and
> have run into problems with create().  I've set it up with a base class that
> establishes a connection to my database, and then I've set up the classes for
> the individual tables and declared the 'is_a' relationship.
> > 
> > #Base class
> > package TestDBIsA::ClassDBI;
> > use base qw(Class::DBI);
> > use strict;
> > use warnings;
> > 
> > my $dbh = TestDBIsA::ClassDBI->connection($dsn, $user, $password)|| die
> "Database connection not made: $DBI::errstr";
> > 
> > 
> > #Tables
> > package TestDBIsA::Person;
> > use base qw(TestDBIsA::ClassDBI);
> > 
> > package TestDBIsA::Artist;
> > use base qw(TestDBIsA::ClassDBI);
> > 
> > TestDBIsA::Artist->is_a( 'pid' => 'TestDBIsA::Person' );
> > 
> > 
> > I have run some simple tests and everything seems to be working with the
> exception of create().  I have found that I can call create() on my parent,
> 'Person', and everything works fine, but that when I call it on my child,
> 'Artist', I get an error message.
> > 
> > TestDBIsA::Artist->create( {
> >   artistid => 81,
> >   alias => 'Manet',
> >   pid => 2
> >   }
> > );
> > 
> > Can't insert new TestDBIsA::Person: DBD::Oracle::st execute failed:
> > ORA-01400:
> > cannot insert NULL into ("JLDOMMER"."PERSON"."PERSONID") (DBD ERROR:
> > OCIStmtExecute) [for Statement "INSERT INTO person (personid)
> > VALUES (?)
> > "] at /usr/lib/perl5/site_perl/5.8.0/DBIx/ContextualFetch.pm line 51.
> >  at /usr/lib/perl5/site_perl/5.8.0/Class/DBI/Relationship/IsA.pm line
> > 257
> > 
> > I'm not sure what I've done wrong.  Does anyone have any thoughts?
> > 
> > Jennifer Dommer
> 


Re: Class::DBI::Relationship::IsA issues with create()
jldommer 20:48 on 26 Feb 2005

Generated at 17:56 on 01 Mar 2005 by mariachi v0.52