Bugzilla – Attachment 13676 Details for
Bug 8164
Replace IFNULL() with COALESCE() in all database calls
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Signed patch
patch.txt (text/plain), 3.36 KB, created by
Marcel de Rooy
on 2012-11-26 11:34:52 UTC
(
hide
)
Description:
Signed patch
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2012-11-26 11:34:52 UTC
Size:
3.36 KB
patch
obsolete
>From d6643f98b4471d4aff518db822405da97c8853aa Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Thu, 23 Aug 2012 16:36:24 +0200 >Subject: [PATCH] Bug 8164: Replace IFNULL with COALESCE >Content-Type: text/plain; charset="utf-8" > >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 <chrisc@catalyst.net.nz> >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > 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 83031be..17330e5 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 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 5682a15..b7b0c77 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=? >-- >1.7.7.6 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 8164
:
11791
|
11811
| 13676