From 43902cf42dab7b56f9215b5c51e4ac8e51fd62c8 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Tue, 12 Apr 2016 15:18:20 +0200 Subject: [PATCH] Bug 15533: Fix 'ambiguous' SQL query in CanItemBeReserved Adding reserves.itemtype made a query to fail in CanItemBeReserved. This patch prefixes the column names with the corresponding table names to prevent that. You can trigger the error by running prove t/db_dependent/Holds.t You should see something like this: Column 'itemtype' in where clause is ambiguous Signed-off-by: Katrin Fischer Signed-off-by: Kyle M Hall --- C4/Reserves.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 55ec002b27..caf44eaef4 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -523,8 +523,8 @@ sub CanItemBeReserved{ # level itemtype if the hold has no associated item $querycount .= C4::Context->preference('item-level_itypes') - ? " AND COALESCE( itype, itemtype ) = ?" - : " AND itemtype = ?" + ? " AND COALESCE( items.itype, biblioitems.itemtype ) = ?" + : " AND biblioitems.itemtype = ?" if ( $ruleitemtype ne "*" ); my $sthcount = $dbh->prepare($querycount); -- 2.39.5