View | Details | Raw Unified | Return to bug 37070
Collapse All | Expand All

(-)a/C4/Barcodes.pm (-1 / +1 lines)
Lines 95-101 sub max { Link Here
95
}
95
}
96
sub db_max {
96
sub db_max {
97
	my $self = shift;
97
	my $self = shift;
98
	my $query = "SELECT max(abs(barcode)) FROM items LIMIT 1"; # Possible problem if multiple barcode types populated
98
	my $query = "SELECT max(abs(CAST(barcode AS UNSIGNED))) FROM items LIMIT 1"; # Possible problem if multiple barcode types populated
99
	my $sth = C4::Context->dbh->prepare($query);
99
	my $sth = C4::Context->dbh->prepare($query);
100
	$sth->execute();
100
	$sth->execute();
101
	return $sth->fetchrow_array || $self->initial;
101
	return $sth->fetchrow_array || $self->initial;
(-)a/t/db_dependent/Barcodes.t (-2 / +23 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 75;
20
use Test::More tests => 76;
21
use Test::Warn;
21
use Test::Warn;
22
use Test::MockModule;
22
use Test::MockModule;
23
use t::lib::TestBuilder;
23
use t::lib::TestBuilder;
Lines 132-137 subtest 'Test generation of hbyymmincr barcodes from DB values' => sub { Link Here
132
    $schema->storage->txn_rollback;
132
    $schema->storage->txn_rollback;
133
};
133
};
134
134
135
subtest 'Test generation of incremental barcodes from DB values' => sub {
136
137
    plan tests => 2;
138
139
    $schema->storage->txn_begin;
140
    $builder->schema->resultset('Issue')->delete_all;
141
    $builder->schema->resultset('Item')->delete_all;
142
    my $barcodeobj;
143
144
    my $item_1 = $builder->build_sample_item(
145
        {
146
            barcode => '1000000000000000'
147
        }
148
    );
149
150
    $barcodeobj = C4::Barcodes->new('incremental');
151
152
    is( $barcodeobj->db_max(), '1000000000000000', "(hbyymmincr) First barcode saved to db is equal to db_max" );
153
    is( $barcodeobj->value(),  '1000000000000001', 'incremental barcode' );
154
155
    $schema->storage->txn_rollback;
156
};
135
157
136
$schema->storage->txn_begin;
158
$schema->storage->txn_begin;
137
159
138
- 

Return to bug 37070