Bug 18601: OAI/Sets.t mangles data due to truncate in ModOAISetsBiblios
This patch replaces the TRUNCATE statement in ModOAISetsBiblios by a DELETE statement. A truncate will cause an implicit commit and will therefore commit the transaction started in the test script. Also simplifying the module load in the test script. Test plan: Do not apply this patch and observe that biblio records are added to your database by running t/db_dependent/OAI/Sets.t. Apply this patch, run the test again and verify that it does no longer add records to your biblio table. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Josef Moravec <josef.moravec@gmail.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
323cc1501f
commit
e0444e8600
|
|
@ -525,7 +525,7 @@ sub CalcOAISetsBiblio {
|
|||
};
|
||||
ModOAISetsBiblios($oai_sets_biblios);
|
||||
|
||||
ModOAISetsBiblios truncate oai_sets_biblios table and call AddOAISetsBiblios.
|
||||
ModOAISetsBiblios deletes all records from oai_sets_biblios table and calls AddOAISetsBiblios.
|
||||
This table is then used in opac/oai.pl.
|
||||
|
||||
=cut
|
||||
|
|
@ -537,7 +537,7 @@ sub ModOAISetsBiblios {
|
|||
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $query = qq{
|
||||
TRUNCATE TABLE oai_sets_biblios
|
||||
DELETE FROM oai_sets_biblios
|
||||
};
|
||||
my $sth = $dbh->prepare($query);
|
||||
$sth->execute;
|
||||
|
|
|
|||
|
|
@ -17,40 +17,20 @@
|
|||
# with Koha; if not, see <http://www.gnu.org/licenses>.
|
||||
|
||||
use Modern::Perl;
|
||||
use C4::Context;
|
||||
use Test::More tests => 148;
|
||||
|
||||
use Test::More tests => 144;
|
||||
use Test::MockModule;
|
||||
use Test::Warn;
|
||||
use MARC::Record;
|
||||
|
||||
use Koha::Database;
|
||||
use C4::Biblio;
|
||||
use C4::OAI::Sets;
|
||||
|
||||
BEGIN {
|
||||
use_ok('C4::OAI::Sets');
|
||||
use_ok('MARC::Record');
|
||||
use_ok('C4::Biblio');
|
||||
}
|
||||
can_ok(
|
||||
'C4::OAI::Sets', qw(
|
||||
GetOAISets
|
||||
GetOAISet
|
||||
GetOAISetBySpec
|
||||
ModOAISet
|
||||
DelOAISet
|
||||
AddOAISet
|
||||
GetOAISetsMappings
|
||||
GetOAISetMappings
|
||||
ModOAISetMappings
|
||||
GetOAISetsBiblio
|
||||
DelOAISetsBiblio
|
||||
CalcOAISetsBiblio
|
||||
ModOAISetsBiblios
|
||||
UpdateOAISetsBiblio
|
||||
AddOAISetsBiblios )
|
||||
);
|
||||
|
||||
|
||||
my $schema = Koha::Database->new->schema;
|
||||
$schema->storage->txn_begin;
|
||||
my $dbh = C4::Context->dbh;
|
||||
$dbh->{AutoCommit} = 0;
|
||||
$dbh->{RaiseError} = 1;
|
||||
|
||||
$dbh->do('DELETE FROM oai_sets');
|
||||
$dbh->do('DELETE FROM oai_sets_descriptions');
|
||||
$dbh->do('DELETE FROM oai_sets_mappings');
|
||||
|
|
@ -632,4 +612,4 @@ sub create_helper_biblio {
|
|||
return $biblionumber;
|
||||
}
|
||||
|
||||
$dbh->rollback;
|
||||
$schema->storage->txn_rollback;
|
||||
|
|
|
|||
Loading…
Reference in New Issue