From 27e449dd7d73786e3d8ba4b51b7189ce43787bde Mon Sep 17 00:00:00 2001
From: Michael Hafen <michael.hafen@washk12.org>
Date: Wed, 2 Nov 2022 12:14:19 -0600
Subject: [PATCH] Bug 14783 Followup - MySQL doesn't like selecting from a
 table it's updating
Content-Type: text/plain; charset="utf-8"

The value has to be selected separately.
---
 installer/data/mysql/db_revs/220600064.pl | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/installer/data/mysql/db_revs/220600064.pl b/installer/data/mysql/db_revs/220600064.pl
index afd6b73d88..e5fa6f9ec5 100755
--- a/installer/data/mysql/db_revs/220600064.pl
+++ b/installer/data/mysql/db_revs/220600064.pl
@@ -12,11 +12,17 @@ return {
             VALUES ('OPACAllowUserToChangeBranch','','Pending, In-Transit, Suspended','Allow users to change the library to pick up a hold for these statuses:','multiple');
         });
 
+	my ($value) = $dbh->selectrow_array(q{
+            SELECT CASE WHEN value=1 THEN 'intransit' ELSE '' END
+            FROM systempreferences
+            WHERE variable='OPACInTransitHoldPickupLocationChange'
+        });
+
         $dbh->do(q{
             UPDATE systempreferences
-            SET value=(SELECT CASE WHEN value=1 THEN 'intransit' ELSE '' END FROM systempreferences WHERE variable='OPACInTransitHoldPickupLocationChange')
+            SET value=(?)
             WHERE variable='OPACAllowUserToChangeBranch'
-        });
+        },undef,$value);
 
         say $out "Added new system preference 'OPACAllowUserToChangeBranch'";
 
-- 
2.34.1