From 45389c08a4fbff41bb2b3a9334a5398fe9ffbf69 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 23 Aug 2012 16:36:24 +0200 Subject: [PATCH] Bug 8293: 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) --- 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 9678ffc..245fb54 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -1638,8 +1638,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 5874a93..c8389a3 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 20f3620..3625486 100644 --- a/C4/VirtualShelves.pm +++ b/C4/VirtualShelves.pm @@ -454,7 +454,7 @@ sub ShelfPossibleAction { return 0 unless defined($shelfnumber); 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=? -- 1.7.10.4