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

(-)a/Koha/Schema/Result/Item.pm (-6 / +6 lines)
Lines 927-950 __PACKAGE__->might_have( Link Here
927
  { cascade_copy => 0, cascade_delete => 0 },
927
  { cascade_copy => 0, cascade_delete => 0 },
928
);
928
);
929
929
930
=head2 tmp_holdsqueues
930
=head2 tmp_holdsqueue
931
931
932
Type: has_many
932
Type: might_have
933
933
934
Related object: L<Koha::Schema::Result::TmpHoldsqueue>
934
Related object: L<Koha::Schema::Result::TmpHoldsqueue>
935
935
936
=cut
936
=cut
937
937
938
__PACKAGE__->has_many(
938
__PACKAGE__->might_have(
939
  "tmp_holdsqueues",
939
  "tmp_holdsqueue",
940
  "Koha::Schema::Result::TmpHoldsqueue",
940
  "Koha::Schema::Result::TmpHoldsqueue",
941
  { "foreign.itemnumber" => "self.itemnumber" },
941
  { "foreign.itemnumber" => "self.itemnumber" },
942
  { cascade_copy => 0, cascade_delete => 0 },
942
  { cascade_copy => 0, cascade_delete => 0 },
943
);
943
);
944
944
945
945
946
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2023-05-12 18:18:47
946
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2023-07-26 15:16:46
947
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:HMU2tnuIRypuatz/J5683A
947
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:77fdafpHCGzK6+An02hikA
948
948
949
__PACKAGE__->belongs_to( biblioitem => "Koha::Schema::Result::Biblioitem", "biblioitemnumber" );
949
__PACKAGE__->belongs_to( biblioitem => "Koha::Schema::Result::Biblioitem", "biblioitemnumber" );
950
950
(-)a/Koha/Schema/Result/TmpHoldsqueue.pm (-12 / +19 lines)
Lines 33-39 __PACKAGE__->table("tmp_holdsqueue"); Link Here
33
33
34
  data_type: 'integer'
34
  data_type: 'integer'
35
  is_foreign_key: 1
35
  is_foreign_key: 1
36
  is_nullable: 1
36
  is_nullable: 0
37
37
38
=head2 barcode
38
=head2 barcode
39
39
Lines 123-129 __PACKAGE__->add_columns( Link Here
123
  "biblionumber",
123
  "biblionumber",
124
  { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
124
  { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
125
  "itemnumber",
125
  "itemnumber",
126
  { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
126
  { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
127
  "barcode",
127
  "barcode",
128
  { data_type => "varchar", is_nullable => 1, size => 20 },
128
  { data_type => "varchar", is_nullable => 1, size => 20 },
129
  "surname",
129
  "surname",
Lines 159-164 __PACKAGE__->add_columns( Link Here
159
  },
159
  },
160
);
160
);
161
161
162
=head1 PRIMARY KEY
163
164
=over 4
165
166
=item * L</itemnumber>
167
168
=back
169
170
=cut
171
172
__PACKAGE__->set_primary_key("itemnumber");
173
162
=head1 RELATIONS
174
=head1 RELATIONS
163
175
164
=head2 biblionumber
176
=head2 biblionumber
Lines 208-224 __PACKAGE__->belongs_to( Link Here
208
  "itemnumber",
220
  "itemnumber",
209
  "Koha::Schema::Result::Item",
221
  "Koha::Schema::Result::Item",
210
  { itemnumber => "itemnumber" },
222
  { itemnumber => "itemnumber" },
211
  {
223
  { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
212
    is_deferrable => 1,
213
    join_type     => "LEFT",
214
    on_delete     => "CASCADE",
215
    on_update     => "CASCADE",
216
  },
217
);
224
);
218
225
219
226
220
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-11-04 22:42:42
227
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2023-07-26 15:16:46
221
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:RdIrLi+vbzj3ab/UP7e9pw
228
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Va8u8f6X3nZxEJULOMF31A
222
229
223
__PACKAGE__->add_columns(
230
__PACKAGE__->add_columns(
224
    '+item_level_request' => { is_boolean => 1 }
231
    '+item_level_request' => { is_boolean => 1 }
Lines 273-283 __PACKAGE__->belongs_to( Link Here
273
);
280
);
274
281
275
sub koha_object_class {
282
sub koha_object_class {
276
    'Koha::HoldsQueueItem';
283
    'Koha::Hold::HoldsQueueItem';
277
}
284
}
278
285
279
sub koha_objects_class {
286
sub koha_objects_class {
280
    'Koha::HoldsQueueItems';
287
    'Koha::Hold::HoldsQueueItems';
281
}
288
}
282
289
283
1;
290
1;
(-)a/installer/data/mysql/atomicupdate/bug_32966.pl (+18 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number  => "28966",
5
    description => "Holds queue view too slow to load for large numbers of holds",
6
    up          => sub {
7
        my ($args) = @_;
8
        my ( $dbh, $out ) = @$args{qw(dbh out)};
9
10
        unless ( primary_key_exists( 'tmp_holdsqueue', 'itemnumber' ) ) {
11
            $dbh->do(
12
                q{ALTER TABLE tmp_holdsqueue ADD PRIMARY KEY (itemnumber)}
13
            );
14
        }
15
16
        say $out "Set primary key for table 'tmp_holdsqueue' to 'itemnumber'";
17
    },
18
};
(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 5885-5890 CREATE TABLE `tmp_holdsqueue` ( Link Here
5885
  `notes` mediumtext DEFAULT NULL,
5885
  `notes` mediumtext DEFAULT NULL,
5886
  `item_level_request` tinyint(4) NOT NULL DEFAULT 0,
5886
  `item_level_request` tinyint(4) NOT NULL DEFAULT 0,
5887
  `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'date and time this entry as added/last updated',
5887
  `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'date and time this entry as added/last updated',
5888
  PRIMARY KEY (`itemnumber`),
5888
  KEY `tmp_holdsqueue_ibfk_1` (`itemnumber`),
5889
  KEY `tmp_holdsqueue_ibfk_1` (`itemnumber`),
5889
  KEY `tmp_holdsqueue_ibfk_2` (`biblionumber`),
5890
  KEY `tmp_holdsqueue_ibfk_2` (`biblionumber`),
5890
  KEY `tmp_holdsqueue_ibfk_3` (`borrowernumber`),
5891
  KEY `tmp_holdsqueue_ibfk_3` (`borrowernumber`),
(-)a/t/db_dependent/TestBuilder.t (-13 / +9 lines)
Lines 285-291 subtest 'Test build with NULL values' => sub { Link Here
285
285
286
286
287
subtest 'Tests for delete method' => sub {
287
subtest 'Tests for delete method' => sub {
288
    plan tests => 12;
288
    plan tests => 11;
289
289
290
    $schema->storage->txn_begin;
290
    $schema->storage->txn_begin;
291
291
Lines 304-326 subtest 'Tests for delete method' => sub { Link Here
304
304
305
305
306
    # Test delete in table without primary key (..)
306
    # Test delete in table without primary key (..)
307
    is( $schema->source('TmpHoldsqueue')->primary_columns, 0,
307
    is( $schema->source('AccountCreditTypesBranch')->primary_columns, 0,
308
        'Table without primary key detected' );
308
        'Table without primary key detected' );
309
    my $bibno = $builder->build_sample_biblio->biblionumber;
309
    my $cnt1 = $schema->resultset('AccountCreditTypesBranch')->count;
310
    my $cnt1 = $schema->resultset('TmpHoldsqueue')->count;
310
    # Insert a new record in AccountCreditTypesBranch with that biblionumber
311
    # Insert a new record in TmpHoldsqueue with that biblionumber
311
    my $rec = $builder->build({ source => 'AccountCreditTypesBranch' });
312
    my $val = { biblionumber => $bibno };
312
    my $cnt2 = $schema->resultset('AccountCreditTypesBranch')->count;
313
    my $rec = $builder->build({ source => 'TmpHoldsqueue', value => $val });
314
    my $cnt2 = $schema->resultset('TmpHoldsqueue')->count;
315
    is( defined($rec) && $cnt2 == $cnt1 + 1 , 1, 'Created a record' );
313
    is( defined($rec) && $cnt2 == $cnt1 + 1 , 1, 'Created a record' );
316
    is( $builder->delete({ source => 'TmpHoldsqueue', records => $rec }),
314
    is( $builder->delete({ source => 'AccountCreditTypesBranch', records => $rec }),
317
        undef, 'delete returns undef' );
315
        undef, 'delete returns undef' );
318
    is( $rec->{biblionumber}, $bibno, 'Hash value untouched' );
316
    is( $schema->resultset('AccountCreditTypesBranch')->count, $cnt2,
319
    is( $schema->resultset('TmpHoldsqueue')->count, $cnt2,
320
        "Method did not delete record in table without PK" );
317
        "Method did not delete record in table without PK" );
321
318
322
    # Test delete with NULL values
319
    # Test delete with NULL values
323
    $val = { branchcode => undef };
320
    my $val = { branchcode => undef };
324
    is( $builder->delete({ source => 'Branch', records => $val }), 0,
321
    is( $builder->delete({ source => 'Branch', records => $val }), 0,
325
        'delete returns zero for an undef search with one key' );
322
        'delete returns zero for an undef search with one key' );
326
    $val = { module_bit => 1, #catalogue
323
    $val = { module_bit => 1, #catalogue
327
- 

Return to bug 28966