Fix rollbacks calls properly here.

Upon fixing the reference counter thing in the previous commit, this bug
caused tests to fail.  We have to _rollback() properly any time we've
called _begin_work(), particularly before die()'ing after a
_begin_work().
This commit is contained in:
Bradley M. Kuhn 2015-12-16 20:11:50 -08:00
parent ea60b11965
commit 031fbab35a

View file

@ -389,15 +389,17 @@ sub addRequestConfigurations($$$) {
my $requestId = $self->addRequestType($requestType);
die "addRequestConfigurations: unable to create request configurations"
unless defined $requestType;
if (not defined $requestType) {
$self->_rollback();
die "addRequestConfigurations: unable to create request configurations";
}
my %descriptions;
my $sth = $self->dbh->prepare("INSERT INTO request_configuration(request_type_id, description) " .
"VALUES(?, ?)");
foreach my $description (@{$descriptionListRef}) {
if (defined $descriptions{$description}) {
$self->dbh->rollback();
$self->_rollback();
die "addRequestConfigurations: attempt to create duplicate request_configuration \"$description\" for requestType, \"$requestType\"";
}
$sth->execute($requestId, $description);