From 30d187c7f9bd1b98a28bf686c4131a93a57e69a5 Mon Sep 17 00:00:00 2001
From: Julian Maurice <julian.maurice@biblibre.com>
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
---
C4/Reserves.pm | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/C4/Reserves.pm b/C4/Reserves.pm
index 55ec002..caf44ea 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.1.4