From f4b7701c4c1e574ebe29e05db694d131d2799b35 Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Wed, 28 Jan 2015 02:26:47 -0800 Subject: [PATCH] optimize cust_pay__otaker_ivan upgrade fix (pretty obsolete at this point?) --- FS/FS/cust_pay.pm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm index 87fad02f1..df567a5c1 100644 --- a/FS/FS/cust_pay.pm +++ b/FS/FS/cust_pay.pm @@ -942,10 +942,11 @@ sub _upgrade_data { #class method #not the most efficient, but hey, it only has to run once - my $where = "WHERE ( otaker IS NULL OR otaker = '' OR otaker = 'ivan' ) ". - " AND usernum IS NULL ". - " AND 0 < ( SELECT COUNT(*) FROM cust_main ". - " WHERE cust_main.custnum = cust_pay.custnum ) "; + my $where = " WHERE ( otaker IS NULL OR otaker = '' OR otaker = 'ivan' ) + AND usernum IS NULL + AND EXISTS ( SELECT 1 FROM cust_main + WHERE cust_main.custnum = cust_pay.custnum ) + "; my $count_sql = "SELECT COUNT(*) FROM cust_pay $where"; -- 2.11.0