bug 605884: make MARC expert search of control fields work
authorgmc <gmc@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 15 Jul 2010 13:52:06 +0000 (13:52 +0000)
committergmc <gmc@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 15 Jul 2010 13:52:06 +0000 (13:52 +0000)
Allows users to search on the 001 and 003 fields, for example.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
git-svn-id: svn://svn.open-ils.org/ILS/trunk@16938 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/metabib.pm

index dc6bf8b..22cf193 100644 (file)
@@ -445,9 +445,16 @@ sub biblio_multi_search_full_rec {
 
                my @wheres;
                for my $limit (@$limiters) {
-                       push @wheres, "( tag = ? AND subfield LIKE ? AND $fts_where )";
-                       push @binds, $$limit{tag}, $$limit{subfield};
-                       $log->debug("Limiting query using { tag => $$limit{tag}, subfield => $$limit{subfield} }", DEBUG);
+                       if ($$limit{tag} =~ /^\d+$/ and $$limit{tag} < 10) {
+                               # MARC control field; mfr.subfield is NULL
+                               push @wheres, "( tag = ? AND $fts_where )";
+                               push @binds, $$limit{tag};
+                               $log->debug("Limiting query using { tag => $$limit{tag} }", DEBUG);
+                       } else {
+                               push @wheres, "( tag = ? AND subfield LIKE ? AND $fts_where )";
+                               push @binds, $$limit{tag}, $$limit{subfield};
+                               $log->debug("Limiting query using { tag => $$limit{tag}, subfield => $$limit{subfield} }", DEBUG);
+                       }
                }
                my $where = join(' OR ', @wheres);
 
@@ -700,9 +707,16 @@ sub search_full_rec {
        my @binds;
        my @wheres;
        for my $limit (@$limiters) {
-               push @wheres, "( tag = ? AND subfield LIKE ? AND $fts_where )";
-               push @binds, $$limit{tag}, $$limit{subfield};
-               $log->debug("Limiting query using { tag => $$limit{tag}, subfield => $$limit{subfield} }", DEBUG);
+               if ($$limit{tag} =~ /^\d+$/ and $$limit{tag} < 10) {
+                       # MARC control field; mfr.subfield is NULL
+                       push @wheres, "( tag = ? AND $fts_where )";
+                       push @binds, $$limit{tag};
+                       $log->debug("Limiting query using { tag => $$limit{tag} }", DEBUG);
+               } else {
+                       push @wheres, "( tag = ? AND subfield LIKE ? AND $fts_where )";
+                       push @binds, $$limit{tag}, $$limit{subfield};
+                       $log->debug("Limiting query using { tag => $$limit{tag}, subfield => $$limit{subfield} }", DEBUG);
+               }
        }
        my $where = join(' OR ', @wheres);