[CDBI] Best way to tell if two objects are the same?

Bill Moseley moseley at hank.org
Wed Jan 11 18:50:20 GMT 2006

On Wed, Jan 11, 2006 at 06:18:28PM +0000, William Ross wrote:
> just calling id() should work for single-column keys, but with mcpk  
> you would need to call it in list context and compare the lists you  
> get back. The easier way to do essentially the same thing is to call  
> stringify_self() (in which case you can manage special cases by  
> defining a Stringify column set) or _live_object_key() (which also  
> includes the class name).

I need a general case so I'm not sure I can trust Stingify.  Object
can stringify to anything.  Also, _live_object_key is a newer method.

> The overload does seem like a good idea. Maybe just:
>   use overload 'cmp' => sub { $_[0]->_live_object_key cmp $_[1]- 
> >_live_object_key };

Yes, that would be a nice feature.  Not sure what I'd expect 'cmp',
'==' or 'eq', though.

Should this die?  Or it return false?  Or compare against what ever
the object is stringified to?

    if ( $cdbi_object eq 'constant' ) 

Bill Moseley
moseley at hank.org

More information about the ClassDBI mailing list