diff --git a/C4/Barcodes.pm b/C4/Barcodes.pm index dfca945a33..333a8eb8bc 100644 --- a/C4/Barcodes.pm +++ b/C4/Barcodes.pm @@ -94,11 +94,12 @@ sub max { return $self->db_max; } sub db_max { - my $self = shift; - my $query = "SELECT max(abs(CAST(barcode AS UNSIGNED))) FROM items LIMIT 1"; # Possible problem if multiple barcode types populated - my $sth = C4::Context->dbh->prepare($query); - $sth->execute(); - return $sth->fetchrow_array || $self->initial; + my $self = shift; + my $query = "SELECT max(abs(CAST(barcode AS UNSIGNED))) FROM items LIMIT 1" + ; # Possible problem if multiple barcode types populated + my $sth = C4::Context->dbh->prepare($query); + $sth->execute(); + return $sth->fetchrow_array || $self->initial; } sub next_value { my $self = shift; diff --git a/t/db_dependent/Barcodes.t b/t/db_dependent/Barcodes.t index b5a976b841..0232a4a9c9 100755 --- a/t/db_dependent/Barcodes.t +++ b/t/db_dependent/Barcodes.t @@ -141,11 +141,7 @@ subtest 'Test generation of incremental barcodes from DB values' => sub { $builder->schema->resultset('Item')->delete_all; my $barcodeobj; - my $item_1 = $builder->build_sample_item( - { - barcode => '1000000000000000' - } - ); + my $item_1 = $builder->build_sample_item( { barcode => '1000000000000000' } ); $barcodeobj = C4::Barcodes->new('incremental');