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

(-)a/C4/Search.pm (-4 / +16 lines)
Lines 1244-1250 sub buildQuery { Link Here
1244
1244
1245
    # add limits
1245
    # add limits
1246
    my %group_OR_limits;
1246
    my %group_OR_limits;
1247
    my $availability_limit;
1247
    my ( $availability_limit, $component_records_limit, $host_records_limit );
1248
    my $component_records_query = "( Bib-level='a' or Bib-level='b' )";
1248
    foreach my $this_limit (@limits) {
1249
    foreach my $this_limit (@limits) {
1249
        next unless $this_limit;
1250
        next unless $this_limit;
1250
        if ( $this_limit =~ /available/ ) {
1251
        if ( $this_limit =~ /available/ ) {
Lines 1257-1263 sub buildQuery { Link Here
1257
            $limit_cgi  .= "&limit=available";
1258
            $limit_cgi  .= "&limit=available";
1258
            $limit_desc .= "";
1259
            $limit_desc .= "";
1259
        }
1260
        }
1261
        elsif ( $this_limit =~ /^component_records$/ ) {
1262
            $component_records_limit      .= "$component_records_query";
1263
            $limit_cgi  .= "&limit=component_records";
1264
            $limit_desc .= "";
1260
1265
1266
        } elsif ( $this_limit =~ /^exclude_component_records$/ ) {
1267
            $host_records_limit      .= "( (allrecords,AlwaysMatches='') not $component_records_query )";
1268
            $limit_cgi  .= "&limit=exclude_component_records";
1269
            $limit_desc .= "";
1270
        }
1261
        # group_OR_limits, prefixed by mc-
1271
        # group_OR_limits, prefixed by mc-
1262
        # OR every member of the group
1272
        # OR every member of the group
1263
        elsif ( $this_limit =~ /mc/ ) {
1273
        elsif ( $this_limit =~ /mc/ ) {
Lines 1330-1338 sub buildQuery { Link Here
1330
        $limit .= " and " if ( $query || $limit );
1340
        $limit .= " and " if ( $query || $limit );
1331
        $limit .= "($group_OR_limits{$k})";
1341
        $limit .= "($group_OR_limits{$k})";
1332
    }
1342
    }
1333
    if ($availability_limit) {
1343
    foreach my $l ( $availability_limit, $component_records_limit, $host_records_limit ) {
1334
        $limit .= " and " if ( $query || $limit );
1344
        if ($l) {
1335
        $limit .= "($availability_limit)";
1345
            $limit .= " and " if ( $query || $limit );
1346
            $limit .= "($l)";
1347
        }
1336
    }
1348
    }
1337
1349
1338
# for handling ccl, cql, pqf queries in diagnostic mode, skip the rest of the steps
1350
# for handling ccl, cql, pqf queries in diagnostic mode, skip the rest of the steps
(-)a/t/db_dependent/Search.t (-2 / +13 lines)
Lines 661-666 ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],' Link Here
661
    is( $query, "an:42 and (( (allrecords,AlwaysMatches='') and (not-onloan-count,st-numeric >= 1) and (lost,st-numeric=0) ))", 'buildQuery should add the available part to the query if requested with ccl' );
661
    is( $query, "an:42 and (( (allrecords,AlwaysMatches='') and (not-onloan-count,st-numeric >= 1) and (lost,st-numeric=0) ))", 'buildQuery should add the available part to the query if requested with ccl' );
662
    is( $query_desc, 'an:42', 'buildQuery should remove the available part from the query' );
662
    is( $query_desc, 'an:42', 'buildQuery should remove the available part from the query' );
663
663
664
    ( $error, $query, $simple_query, $query_cgi,
665
    $query_desc, $limit, $limit_cgi, $limit_desc,
666
    $query_type ) = buildQuery([], [ 'ccl=an:42' ], [], ['component_records'], [], 0, 'en');
667
    is( $query, "an:42 and (( Bib-level='a' or Bib-level='b' ))", 'buildQuery should add the component_records part to the query if requested with ccl' );
668
    is( $query_desc, 'an:42', 'buildQuery should remove the component_records part from the query' );
669
670
    ( $error, $query, $simple_query, $query_cgi,
671
    $query_desc, $limit, $limit_cgi, $limit_desc,
672
    $query_type ) = buildQuery([], [ 'ccl=an:42' ], [], ['exclude_component_records'], [], 0, 'en');
673
    is( $query, "an:42 and (( (allrecords,AlwaysMatches='') not ( Bib-level='a' or Bib-level='b' ) ))", 'buildQuery should add the exclude_component_records part to the query if requested with ccl' );
674
    is( $query_desc, 'an:42', 'buildQuery should remove the exclude_component_records part from the query' );
675
664
    ( $error, $query, $simple_query, $query_cgi,
676
    ( $error, $query, $simple_query, $query_cgi,
665
    $query_desc, $limit, $limit_cgi, $limit_desc,
677
    $query_desc, $limit, $limit_cgi, $limit_desc,
666
    $query_type ) = buildQuery([], [ 'ccl=an:42' ], [], ['branch:CPL'], [], 0, 'en');
678
    $query_type ) = buildQuery([], [ 'ccl=an:42' ], [], ['branch:CPL'], [], 0, 'en');
Lines 923-929 sub run_unimarc_search_tests { Link Here
923
}
935
}
924
936
925
subtest 'MARC21 + DOM' => sub {
937
subtest 'MARC21 + DOM' => sub {
926
    plan tests => 93;
938
    plan tests => 97;
927
    run_marc21_search_tests();
939
    run_marc21_search_tests();
928
};
940
};
929
941
930
- 

Return to bug 15728