Can't call id() as a class method

[prev] [thread] [next] [Date index for 2005/03/17]

From: Tom Gazzini
Subject: Can't call id() as a class method
Date: 22:44 on 17 Mar 2005
I got this error while using Class::DBI

"Can't call id() as a class method at ... "

With the following code stack:
/usr/local/lib/perl5/5.8.3/Carp.pm:191
/usr/local/lib/perl5/site_perl/5.8.3/Class/DBI.pm:233
/usr/local/lib/perl5/site_perl/5.8.3/Class/DBI.pm:313
/var/www/sites/tubatree/lib/Common/Utils.pm:44
/var/www/sites/tubatree/shop/autohandler.mas:37
/var/www/sites/tubatree/shop/session.mas:27

On examination of the relevant Class::DBI code it becomes kind of clear why
the programmer would have included this validation.

However, from a purely OO perspective, it seems very odd that the primary
key of a DB table class cannot be determined, but that the primary key of an
object can.

What, can the primary key of a table class somehow change when it gets
instantiated? (Or am I missing something?)

There definitely are cases when the primary key of a table class needs to be
found (eg, to construct a query which will then enable the objects to be
created). Is there any particular reason why this is not supported by
Class::DBI?

= Tom

 
> -----Original Message-----
> From: Perrin Harkins [mailto:perrin@xxxx.xxx]
> Sent: 17 March 2005 19:22
> To: kingsley@xxxxxxxxxxxxxxxx.xxx
> Cc: cdbi-talk@xxxxxx.xxxxx.xxx
> Subject: Re: Class::DBI::Loader and accessors
> 
> On Wed, 2005-03-16 at 12:51 -0500, Kingsley Kerce wrote:
> > But I can't find a way to move some add_relationship_type() and
> > columns() invocations -- which must be done for every table class --
> > into my base class.
> 
> I would have expected add_relationship_type to work.  I don't think
> there is an easy way to make the columns() stuff work, since it needs to
> be done for each class, but I might try overriding set_up_table() in the
> base class to add some extra behavior like this.
> 
> >   eval "package Class::DBI::Relationship::HasMany::NoCascadeDelete;
> >
> >         use base 'Class::DBI::Relationship::HasMany';
> >
> >         sub triggers { return () }
> >        ";
> >   confess $@ if $@;
> 
> Nasty.  I'd put that in a separate file.
> 
> - Perrin



(message missing)

Class::DBI::Loader and accessors
Sean Davis 21:10 on 15 Mar 2005

Re: Class::DBI::Loader and accessors
Kingsley Kerce 21:29 on 15 Mar 2005

Re: Class::DBI::Loader and accessors
Perrin Harkins 21:51 on 15 Mar 2005

Re: Class::DBI::Loader and accessors
Kingsley Kerce 22:28 on 15 Mar 2005

Re: Class::DBI::Loader and accessors
Kingsley Kerce 17:51 on 16 Mar 2005

Re: Class::DBI::Loader and accessors
Perrin Harkins 19:22 on 17 Mar 2005

RE: Class::DBI::Loader and accessors
Zhuang Li 18:48 on 17 Mar 2005

RE: Class::DBI::Loader and accessors
Kingsley Kerce 19:07 on 17 Mar 2005

RE: Class::DBI::Loader and accessors
Zhuang Li 20:02 on 17 Mar 2005

RE: Class::DBI::Loader and accessors
Kingsley Kerce 21:02 on 17 Mar 2005

Re: Class::DBI::Loader and accessors
Tony Bowden 23:16 on 17 Mar 2005

RE: Class::DBI::Loader and accessors
Zhuang Li 21:43 on 17 Mar 2005

Can't call id() as a class method
Tom Gazzini 22:44 on 17 Mar 2005

Re: Can't call id() as a class method
Perrin Harkins 22:52 on 17 Mar 2005

Re: Can't call id() as a class method
Tony Bowden 23:15 on 17 Mar 2005

RE: Class::DBI::Loader and accessors
Zhuang Li 21:54 on 23 Mar 2005

Re: Class::DBI::Loader and accessors
Tim Bunce 22:26 on 23 Mar 2005

Re: Class::DBI::Loader and accessors
Tony Bowden 23:00 on 23 Mar 2005

Re: Class::DBI::Loader and accessors
Tony Bowden 23:34 on 23 Mar 2005

RE: Class::DBI::Loader and accessors
Zhuang Li 23:07 on 23 Mar 2005

RE: Class::DBI::Loader and accessors
Zhuang Li 23:50 on 23 Mar 2005

RE: Class::DBI::Loader and accessors
Peter Speltz 00:04 on 24 Mar 2005

Generated at 15:09 on 27 Mar 2005 by mariachi v0.52