Re: Re-inserting a record after delete

[prev] [thread] [next] [Date index for 2005/04/06]

From: Michael Peters
Subject: Re: Re-inserting a record after delete
Date: 17:19 on 06 Apr 2005
Gianni, Andrew wrote:
> I'm running into a problem in testing an application. For testing
> purposes, I need to delete a record from the database, and then turn
> around and put it back in with the same primary key (by making a test
> call to an application function). The problem I'm having is that when I
> try to do the find_or_create with the identical primary key, I get the
> following error:
> 
> Can't locate object method "call_trigger" via package
> "Class::DBI::Object::Has::Been::Deleted" (perhaps you forgot to load
> "Class::DBI::Object::Has::Been::Deleted"?) at
> /usr/local/perl5.6.1/lib/site_perl/5.6.1/Class/DBI.pm line 579, <DATA>
> line 283.
> 
> This isn't surprising to me, but I don't know how to get around it. Or,
> rather, I got around it by seemingly reinitializing access to the table
> by making a retrieve call to the table. But what would be the
> appropriate way to get my table object re-associated with it's correct
> parent object; i.e. not Class::DBI::Object::Has::Been::Deleted?

This is because the Live Object Index (see 
http://search.cpan.org/~tmtm/Class-DBI-0.96/lib/Class/DBI.pm#UNIQUENESS_OF_OBJECTS_IN_MEMORY).
It's designed to prevent having multiple copies of the same object in 
memory at once. Sometimes it does get in the way during testing though. 
All you need to do is add a call to clear_object_index().

     My::DBI::Class->clear_object_index();

        -- 
        Michael Peters
Developer
Plus Three, LP

Re-inserting a record after delete
Gianni, Andrew 17:03 on 06 Apr 2005

Re: Re-inserting a record after delete
Michael Peters 17:19 on 06 Apr 2005

Re: Re-inserting a record after delete
Kingsley Kerce 17:30 on 06 Apr 2005

Generated at 06:54 on 17 May 2005 by mariachi v0.52