From: | "Riley Lynch" <riley [...] shunpiker.org> |
Date: | Tue, 15 Mar 2005 22:02:06 +0000 |
To: | bug-Class-DBI-mysql-FullTextSearch [...] rt.cpan.org |
Subject: | "create" trigger clobbers mysql_insertid on insert |
A Class::DBI class with a registered search function cannot recover mysql_insertid after inserting a row, because the action of the "create" trigger clobbers that value.
Here is a debugger's-eye-view of the problem:
DB<12> x $$MySQLClass::MyBase::_dbh->{mysql_insertid}
0 355
DB<13> l
602==> $self->call_trigger('create', discard_columns => \@discard_columns); # XXX
603
604 # Empty everything back out again!
605: $self->_attribute_delete(@discard_columns);
606: $self->call_trigger('after_create');
607: return $self;
608 }
DB<13> n
Class::DBI::_create(/opt/third-party/lib/perl-5.6.0/site/Class/DBI.pm:605):
605: $self->_attribute_delete(@discard_columns);
DB<13> x $$MySQLClass::MyBase::_dbh->{mysql_insertid}
0 0
Since $dbh->{mysql_insertid} shrugs off any attempt to local'ize it or assign to it, it looks like it's up to this class to stash away a copy in case the caller needs to see it.
Hope this is helpful,
Riley Lynch
Seattle