From: gmc <gmc@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Date: Thu, 15 Jul 2010 13:52:06 +0000 (+0000)
Subject: bug 605884: make MARC expert search of control fields work
X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=1eaa1e9db76c5713ad00fa1fa64dcaad73f212b2;p=contrib%2FConifer.git

bug 605884: make MARC expert search of control fields work

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
---

diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/metabib.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/metabib.pm
index dc6bf8be9b..22cf193571 100644
--- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/metabib.pm
+++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/metabib.pm
@@ -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);