From 8dd92940bb8f3777f63cddf401e6fc01550173c7 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 23 Aug 2012 16:36:24 +0200 Subject: [PATCH] Bug 8164: Replace IFNULL with COALESCE mysql> SELECT IFNULL(0, 123); +----------------+ | IFNULL(0, 123) | +----------------+ | 0 | +----------------+ 1 row in set (0.00 sec) mysql> SELECT IFNULL(1, 123); +----------------+ | IFNULL(1, 123) | +----------------+ | 1 | +----------------+ 1 row in set (0.00 sec) mysql> SELECT IFNULL(NULL, 123); +-------------------+ | IFNULL(NULL, 123) | +-------------------+ | 123 | +-------------------+ 1 row in set (0.00 sec) mysql> SELECT COALESCE(0, 123); +------------------+ | COALESCE(0, 123) | +------------------+ | 0 | +------------------+ 1 row in set (0.00 sec) mysql> SELECT COALESCE(1, 123); +------------------+ | COALESCE(1, 123) | +------------------+ | 1 | +------------------+ 1 row in set (0.00 sec) mysql> SELECT COALESCE(NULL, 123); +---------------------+ | COALESCE(NULL, 123) | +---------------------+ | 123 | +---------------------+ 1 row in set (0.00 sec) Signed-off-by: Chris Cormack Signed-off-by: Marcel de Rooy Signed-off-by: Jared Camins-Esakov --- C4/Acquisition.pm | 4 ++-- C4/Bookseller.pm | 2 +- C4/VirtualShelves.pm | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index 83031becab..17330e5dd9 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -1795,8 +1795,8 @@ sub GetLateOrders { my $having = ""; if ($dbdriver eq "mysql") { $select .= " - aqorders.quantity - IFNULL(aqorders.quantityreceived,0) AS quantity, - (aqorders.quantity - IFNULL(aqorders.quantityreceived,0)) * aqorders.rrp AS subtotal, + aqorders.quantity - COALESCE(aqorders.quantityreceived,0) AS quantity, + (aqorders.quantity - COALESCE(aqorders.quantityreceived,0)) * aqorders.rrp AS subtotal, DATEDIFF(CAST(now() AS date),closedate) AS latesince "; if ( defined $delay ) { diff --git a/C4/Bookseller.pm b/C4/Bookseller.pm index 5874a93681..c8389a3441 100644 --- a/C4/Bookseller.pm +++ b/C4/Bookseller.pm @@ -125,7 +125,7 @@ sub GetBooksellersWithLateOrders { ) AND aqorders.rrp <> 0 AND aqorders.ecost <> 0 - AND aqorders.quantity - IFNULL(aqorders.quantityreceived,0) <> 0 + AND aqorders.quantity - COALESCE(aqorders.quantityreceived,0) <> 0 AND aqbasket.closedate IS NOT NULL "; if ( defined $delay ) { diff --git a/C4/VirtualShelves.pm b/C4/VirtualShelves.pm index 5682a1557e..b7b0c779ee 100644 --- a/C4/VirtualShelves.pm +++ b/C4/VirtualShelves.pm @@ -460,7 +460,7 @@ sub ShelfPossibleAction { my $dbh = C4::Context->dbh; my $query = qq/ - SELECT IFNULL(owner,0) AS owner, category, allow_add, allow_delete_own, allow_delete_other, IFNULL(sh.borrowernumber,0) AS borrowernumber + SELECT COALESCE(owner,0) AS owner, category, allow_add, allow_delete_own, allow_delete_other, COALESCE(sh.borrowernumber,0) AS borrowernumber FROM virtualshelves vs LEFT JOIN virtualshelfshares sh ON sh.shelfnumber=vs.shelfnumber AND sh.borrowernumber=? -- 2.39.5