[CDBI] overloaded operator problem

Rolf Schaufelberger rs at plusw.de
Fri Jun 2 09:05:08 BST 2006


> On Thu, 2006-06-01 at 15:53 +0200, Rolf Schaufelberger wrote:
> > Operation `eq': no method found,
> > left argument in overloaded package PW::DB::Company,
> > right argument has no overloaded magic
> > at /serv/perl/lib//PW/PermissionManager.pm line 15.
> > context:
> > ...
> > 11:
> > 12:  	sub grants($$$$) {
> > 13:  	my ( $this, $user, $action, $resource ) = @_;
> > 14:  	return 0 unless $action eq 'admin';
> > 15:  	return 1 if ( $user->company_id() eq '1' || $user->company_id() eq
> > '2' );
> > 16:  	return 0;
> > 17:  	}
>
> Try changing those to $user->company_id()->id().  
That seems to work. I write "seems" because this is on of these very strange 
errors. Before I had 
 $user->company_id() == 1 
an it worked for months, suddenly reporting this error , changed it to string 
comparison, working since then, got this error now again in our development 
branch. Very strange...

> I always change my 
> accessor names for things with a has_a on them so that I can call
> $user->company() instead.
>
> Also, is company_id part of the primary key for $user?
>
No. Both tables a a single primary key "id".

> - Perrin

CDBI Version is 0.96, i have another system running with 3.0.14 and the error 
doesn't appear there. 


Rolf



More information about the ClassDBI mailing list